Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
do some googling about time complexity. If you don't understand that, you won't be able to solve many problmes here (especially "why" you cannot solve them)
that has nothing to do with the current problem. Copying the array at the beginning of the function is O(n) step. The next part of the solution is still O(n²).
Well, you couldn't try it earlier since it timed out. Something else about your code is wrong, inspect it carefully.
Here's the prob. In some cases, you'll need to copy the array but in this case you don't. Just change it to
ls
.This has been asked multiple times already. You can't see the original posts (because they contain spoilers) but they are all the same - people are implementing
O(n^2)
solutions when anO(n)
one is required. Your approach is wrong.Thanks, I'll take a look.
Note: Please wrap code with three backticks to format it.
This comment is hidden because it contains spoiler information about the solution
That means your code is not efficient enough. It runs at least 100 tests, so you need to write efficient code (that runs fast).
Also, next time mark your question as a "question" because it is one. :)