Company: IBM_._
Difficulty: medium
Valid Brackets Problem Description You are given an array of strings, each containing only the characters '(', ')', '{', '}', '[', and ']'. For each string, decide whether it is valid. A string qualifies as valid when: Every opening bracket is paired with a closing bracket of the same type. Brackets close in the correct nested order. The function isValidBrackets takes one input: string queries[q] : the string queries It should return an array of strings, where each element is "YES" if the corresponding input string is valid, or "NO" otherwise. Examples Example 1: Input: q = 4 queries = ["(){}[]", "{[}]", "{([])}", "}{()("] Checking each bracket sequence: "(){}[]" → Every bracket is correctly paired and nested. "{[}]" → The '{' never gets its closing bracket. "{([])}" → Brackets are properly nested and matched. "}{()(" → Begins with an unmatched closing bracket '}'. Output: ["YES", "NO", "YES", "NO"] Explanation: So the result is ["YES", "NO", "YES", "NO"]. Example 2: Input: 3 [()]{} {[