Parentheses checking

0

0 votes
Problem

Given An integer T denoting Testcase

followed by a  string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is correct or not.

Print "YES" if the String is correct and "NO" if the string is not valid.

(all letters in "YES" and "NO" must be Capital)

An input string is valid if:

  1. Open brackets must be closed by the same type of brackets.
  2. Open brackets must be closed in the correct order 

Input format

First line is an Integer T denoting the testcase

next 2T include the test case

First line the size of string N and the next line is the string S

Time Limit: 5
Memory Limit: 256
Source Limit:
Editor Image

?