Validate Nested Parentheses, Brackets, and Braces
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: easy
Interview Round: Online Assessment
Overview: Validate nested parentheses, brackets, and braces with correct handling of empty input, mismatched closing symbols, and unfinished groups.
Constraints
- The input contains only (, ), [, ], {, and } and has length 0 through 100000.
- A closer must match the most recent unmatched opener; every opener must eventually close.
- Empty input is valid and adjacent complete groups are allowed.
- Return a boolean; equal bracket counts alone do not establish correct nesting.
Examples
Input: ('{[()]}[]',)
Expected Output: True
Explanation: Nested and adjacent groups can both be valid.
Input: ('([)]',)
Expected Output: False
Explanation: Matching counts do not permit crossing nesting.