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.
me too!
This comment is hidden because it contains spoiler information about the solution
It will never fail since it's javascript. The worst it could get is a NaN value for
time
.Nice solution !
If i understand your code correctly , the time complexity of this solution is O(n^2) ?
1.the main while loop
2.the if contains method inside the main loop
You missed the point. There can be multiple unknown
true
cells since the description specified dead ends.This is using "loops". Recursion vs iteration. Worst case scenario, it will walk down every dead end before finding the exit.
This solution is actually kind of bad practice due to the contradicting use of booleans. Makes it confusing for anyone coming back to the code. The
walked
hash essentially treatstrue
as a wall while themap
array treatsfalse
as a wall. Wall in this sense just means a path that can be ignored.This comment is hidden because it contains spoiler information about the solution
First iterations would have a lot of characters to check for in the text, but the last ones would run much quicker because you are discarding the already checked characters.
Yeah, I guess you're right, done :)