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.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.
I could be wrong (still learning Java), but doesn't this have high time complexity (lines 8 and 9) compared to other solutions?
Yeah, I guess you're right, done :)
Kata should be updated to make explicit for languages like Ruby that mutating the original string is disallowed (otherwise the random tests break).
I get that it's often best practice, but it's not obvious from the instructions or the sample cases.
This comment is hidden because it contains spoiler information about the solution
I see
Thanks!
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
this might have a little more overhead than the top answer, but the intention is much much clearer.
This comment is hidden because it contains spoiler information about the solution
Loading more items...