Ad
  • Default User Avatar

    I'm unable to get anywhere on the JavaScript implementation. Can we please have a complete view of the Node class/object implementation? Neither node.next or node.getNext() appear to be doing anything. Also, the nodes have no values, as near as I can tell. Which could be the issue with trying to determine if the next are doing anything.

  • Default User Avatar

    These nodes apparently have no values or identifying properties. I can't tell if my attempts to increment them is working at all. This description really needs more info on how to use these nodes.

  • Default User Avatar

    Contrary to vincaslt's comment, I believe n is necessary in order to catch the condition vectorjohn points out.

  • Default User Avatar

    I wonder what the time difference is though. Its probably the same, depending on push() implementation. Using the length to determine the next index should be O(1), right? I guess if they're the same time complexity, push is a LITTLE clearer. I still love the solution though.

  • Default User Avatar

    I used reduce. Look at my solution if you'd like to see an example.

  • Default User Avatar

    This solution is beautiful. Well done.

  • Default User Avatar

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

  • Default User Avatar

    Hmmm, I didn't notice that info either. The problem statement is such a mess I didn't get that far down. I cant help but think the problem statement could be re-written so the problem's definition of 'needless' is made clearer, earlier. Otherwise the spirit of the premise for the problem (trying to remove all unnecessary directions) confuses people.

  • Default User Avatar

    There are so many people having trouble with the test cases and they are just being pushed aside and told it works correctly. The issue is the problem statement and it needs to be corrected. Poeple pointing out issues shouldn't be essentially ignored. The problem statement makes it seem like you want ALL superfluous directions removed, so [N, W, S, E] should return [], NOT [N, W, S, E]. However, it seems to me the kata author actually just wants the consecutive opposing directions removed, so [N, S, E, W] WOULD return [], but not [N, W, S, E];