• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests
January 06, 2024 |430 Views
SDE Sheet - Parenthesis Checker
  Share   Like
Description
Discussion

This video is part of the Stack and Queue section under the GFG SDE Sheet.

In this problem, we are given an expression string x. Examine whether the pairs and the orders of {,},(,),[,] are correct in exp.
For example, the function should return 'true' for exp = [()]{}{[()()]()} and 'false' for exp = [(]).

Note: The drive code prints "balanced" if the function returns true, otherwise it prints "not balanced".

Example :

Input:
{([])}
Output: 
true
Explanation: 
{ ( [ ] ) }. Same colored brackets can form balanced pairs, with 0 number of unbalanced bracket.

Try it out before watching the implementation of the problem in the video. We recommend watching the video, even if you can solve the problem. You may discover something new. All the best!!!

Do check out:-
Article: https://www.geeksforgeeks.org/check-for-balanced-parentheses-in-an-expression/
Problem: https://www.geeksforgeeks.org/problems/parenthesis-checker2744/1
SDE Sheet Link: https://www.geeksforgeeks.org/sde-sheet-a-complete-guide-for-sde-preparation/

Read More