Ad
  • Custom User Avatar

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

  • Custom User Avatar

    I'm not sure how I can help without giving you the answer =/ All I can say is that: if both arrays are empty, result should be true, not false.

    Try again, and if you still don't understand, try asking on CW gitter channel.

  • Custom User Avatar

    Well, if a is [] and b is [], are they equal? :P There's still a small logical error in that if statement.

  • Custom User Avatar

    I'm afraid your logic isn't quite correct. You're failing the classic test of this kata - [2, 2, 3] and [4, 9, 9] - which should return false.

    You can also see some other tests that you're failing by simply printing input arrays, for example: System.out.println(java.util.Arrays.toString(a));

  • Custom User Avatar

    I am not going to tell, and I leave it for you to figure out. A couple of hints tho:

    • you can print n to console and see what is the last n passed to the function before it hangs. Be careful tho, because with how CW works, not all logs can be visible when timeout occurs, and non-flushed output will be lost and left not visible. You might need to force the flush after every write (but you might not, it depends).
    • you can run your solution locally, on your machine, in a loop, for all numbers from 0 to 100. Or from 0 to 1000, or from 0 to one million, and see if it completes normally or hangs.

    Good luck!

  • Custom User Avatar

    Your solution is good enough in terms of performance for current tests (not that it's performant in general, the problem can be solved much faster, but for this kata and these tests, your solution is OK).
    The problem with it, and the reason of timeouts, is that it does not handle some edge cases too well. There are inputs which cause it to get into infinite loop.

  • Custom User Avatar

    Hi @fr33mad, you will have to find a more efficient solution to pass the kata. Often the sample tests are only useful for checking if your code works in the most basic way, but then there are more tests when you click on ATTEMPT. This includes different tests, more diffuicult tests, edge cases, and random tests.