Validate bracket sequence
Company: Intuit
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: easy
Interview Round: Technical Screen
Quick Answer: This question evaluates understanding of bracket matching and string parsing, testing competency with basic data structures and algorithmic reasoning such as stack-based matching and correct handling of nested delimiters.
Constraints
- 0 <= len(s) <= 100000
- s contains only the characters '(', ')', '[', ']', '{', and '}'
Examples
Input: "()[]{}"
Expected Output: True
Explanation: Each bracket is properly opened and closed in the correct order.
Input: "([)]"
Expected Output: False
Explanation: The ')' tries to close '(' while '[' is still open, so the order is invalid.
Input: "{[]}"
Expected Output: True
Explanation: The nested brackets are correctly matched: '[' closes before '{' closes.
Input: ""
Expected Output: True
Explanation: An empty string has no unmatched brackets, so it is valid.
Input: "]"
Expected Output: False
Explanation: A closing bracket appears without any earlier matching opening bracket.
Input: "((("
Expected Output: False
Explanation: There are opening brackets left unmatched at the end of the string.