Balanced Parentheses - C# Advanced
Здравейте задачата е Balanced Parentheses от C# Advanced. Дава ми 87 точки и ми се чупи последния тест. Предполагам теста който ми се чупи е (){([])}, но не мога да измисля как да си променя кода. Може ли някой да ми даде насока какво да направя?
https://pastebin.com/B5AQszAM
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.
Output
- For each test case, print on a new line "YES" if the parentheses are balanced.
Otherwise, print "NO". Do not print the quotes.
Constraints
- 1 ≤ lens ≤ 1000, where lens is the length of the sequence.
- Each character of the sequence will be one of {, }, (, ), [, ].
Examples
Input |
Output |
{[()]} |
YES |
{[(])} |
NO |
{{[[(())]]}} |
YES |