Ad
  • Custom User Avatar

    @AlejandorLazaro if you imply using a hash that's not O(n) algorithm; it's O(n.log(n))

  • Custom User Avatar

    nice kata; took me quite a while to figure out. did it way to complicated still...

  • Custom User Avatar

    Thank you very much! This particular submission actually is inspired from one of the interview questions I was given for the current job I'm working in. If it weren't for Codewars, I don't even think I would've gotten in! I'm glad to see that this platform is helping others just as much as it has helped me and that I can give back to the community.

    Happy coding!

  • Custom User Avatar

    First thing I would do is to analyze your code loops and make absolutely sure that you're running a O(n) algorithm. Walk through your code with an example on pen and paper and see if your solution really does only visit each element once. If you want to test your code somewhere else, I suggest using https://ideone.com as a good sandbox playground for your code.

    Also, remember that Codewars is still growing and sometimes experiences submission problems. While rare, it may be an issue on their side. Just hang in there and try again! :)

  • Custom User Avatar

    Just as bkaes said, the goal is to return the pair of indices where the second index is the smallest.

    To more easily imagine the scenario, if it were possible to solve this problem in a single left-to-right pass, then it would make sense that the pair to be returned would be the first "complete" pair encountered. Any numbers after the second index of the pair would not even be visited.

  • Custom User Avatar

    I am certain that my worst case complexity is O(n) yet, after I pass all tests and submit, I get failure due to a run time error taking longer than 6000 (ms maybe, I don't remember the unit). Why is this happening?

  • Custom User Avatar

    You are supposed to provide correct output for empty plugboard (i. e. plugboard = Plugboard(), no arguments provided).

  • Custom User Avatar

    I pass all the tests and then when I submit I also show that I pass all the tests, however, a TypeError occurs: Traceback:
    in
    TypeError: init() takes exactly 2 arguments (1 given)

    which does not occur on my local machine when I run this program. My init function is defined with (self, wires):

    So, I don't understand what the issue is. Any ideas?