We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Stacks: Balanced Brackets
- Discussions
Stacks: Balanced Brackets
Stacks: Balanced Brackets
Sort by
recency
|
409 Discussions
|
Please Login in order to post a comment
Python O(n)
Clean Ruby solution:
JavaScript Solution: ========= PSEUDOCODE ========== 1. Take one empty stack and a variable name valid with true initial value 2. Travell to each bracket of the input 3. if we are having left bracket push it into the stack 4. if we are having right bracket , then pop a bracket from the stack. . check if the poped bracked and the right bracket are compliment to eachother or not OR check stack is empty , and update the variable valid accordingly. . complete it for all three type of right bracket 5. if valid == true and stack is empty return 'YES' otherwise return 'NO'.
Here is working code :
**Getting seg fault please someone help **
** Getting seg fault please someone help **