05. Balanced Parentheses - Stacks and Queues
Опитвам се да реша задачата Balanced Parentheses със един stack и един queue, но ми гърми посленият тест (87/100) и не мога да си открия грешката. https://pastebin.com/5ExWmhMh
Условие:
Balanced Parentheses
Given a sequence consisting of parentheses, determine whether the expression is balanced. A sequence of parentheses is balanced if every open parenthesis can be paired uniquely with a closed parenthesis that occurs after the former. Also, the interval between them must be balanced.
You will be given three types of parentheses: (, {, and [.
{[()]} - This is a balanced parenthesis.
{[(])} - This is not a balanced parenthesis.
Input
Each input consists of a single line, the sequence of parentheses.
1 ≤ Length of sequence ≤ 1000.
Each character of the sequence will be one of the following: {, }, (, ), [, ].
Output
For each test case, print on a new line "YES" if the parentheses are balanced. Otherwise, print "NO".