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.
Cool solution! But is it O(n^2) compared to O(n) for the stack approach?
Hi pretty cool,
what i have to mention is, what exactly are you doing if
the use case changes and you would have to compute any string within any valid braces?
To add on, I think it's also because the pair of brackets will only be replaced with "" if the open and close brackets are in the correct order, of the same type as well as next to each other, on each iteration. By the last iteration, it should give you a "" if the bracket orderings are valid.
ofcourse its a performance killer, but we try to be smart here by providing a solution with less lines possible.
Bad code.
This comment is hidden because it contains spoiler information about the solution
Please use spoiler flag next time.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
I was wondering if someone could explain how this works, particularly if braces are out of order? For instance, if braces was "({[}])", wouldn't this code change the string to "{[}]", then to "{}"? Wouldn't this disregard the order of braces? I'm relatively new and would greatly appreciate if someone could help me out. Thanks!
you could replace the last few lines with:
return b.length() == 0
Why? Its still O(n).
Good for reading, but bad for perfomance.
can any one tell me why he used \ and why {[()]} is ok but {(}) not ok :/
that's right
Loading more items...