Ad
  • Custom User Avatar

    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)

  • Custom User Avatar

    What's that mean i can't understand. can you pls explain that.

  • Custom User Avatar

    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.

    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²).

  • Custom User Avatar

    Well, you couldn't try it earlier since it timed out. Something else about your code is wrong, inspect it carefully.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    [...ls]

    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.

  • Custom User Avatar

    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 an O(n) one is required. Your approach is wrong.

  • Custom User Avatar

    Thanks, I'll take a look.
    Note: Please wrap code with three backticks to format it.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    thanks steffan, can i send you the code which i have written so that i can come to know what is inefficient. with this i would learn what i have to do for efficient coding. I will appreciate that.

    thanks
    jaspal

  • Custom User Avatar

    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. :)

  • Custom User Avatar

    Hi
    when i try to attempt this kata i am getting this issue 'Execution Timed Out (12000 ms)'
    can anyone help me please.

    thanks