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.
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.
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.
Contrary to vincaslt's comment, I believe n is necessary in order to catch the condition vectorjohn points out.
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.
I used reduce. Look at my solution if you'd like to see an example.
This solution is beautiful. Well done.
This comment is hidden because it contains spoiler information about the solution
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.
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];