Balanced Parentheses Check
Given a string STR
consisting solely of the characters '{', '}', '(', ')', '[', and ']', determine whether the parentheses are balanced.
Input:
The first line contains an integer 'T' representing the number of test cases. Each of the following T lines contains a string representing a test case.
Output:
For each test case, output 'YES' if the expression is balanced and 'NO' otherwise. Each result should be printed on a new line.
Example:
Input:
3
{}[()]
{[}]
({[()]})
Output:
YES
NO
YES
Constraints:
1 <= T <= 10
1 <= N <= 10^5
- Where N is the length of the input string or expression.
Note: You don't need to print anything yourself; just implement the function to solve the problem.
Be the first one to answer
Add answer anonymously...
Top Snapdeal Software Engineer interview questions & answers
Popular interview questions of Software Engineer
Top HR questions asked in Snapdeal Software Engineer
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app