401 data structures and algorithms code challenges
There are 3 types of brackets:
()
[]
{}
Input | Output |
---|---|
{} |
TRUE |
{}(){} |
TRUE |
()[[Extra Characters]] |
TRUE |
(){}[[]] |
TRUE |
{}{Code}[Fellows](()) |
TRUE |
[({}] |
FALSE |
(]( |
FALSE |
{(}) |
FALSE |
Consider these small examples and why they fail.
Input | Output | Why |
---|---|---|
{ |
FALSE |
error unmatched opening { remaining. |
) |
FALSE |
error closing ) arrived without corresponding opening. |
[} |
FALSE |
error closing } . Doesn’t match opening ( . |
None
This one was too hard for me. My solution was a O(N^N)
solution so I asked my classmates what they came up with instead. Emily helpped me write this answer but I’m eventually going to come back to this challenge and solve it my own way.