Solve delimiter and CSV tasks
Company: Meta
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Technical Screen
Quick Answer: This question evaluates skills in string parsing and bracket balancing, CSV/file parsing and joining, computation of derived values, and sorting, emphasizing data representation, correctness, and algorithmic efficiency.
Part 1: Validate Bracket Sequences
Constraints
- 0 <= len(s) <= 100000
- Each character in `s` is one of: `(`, `)`, `[`, `]`, `{`, `}`
Examples
Input: '()[]{}'
Expected Output: True
Explanation: Each opening bracket has a matching closing bracket in the correct order.
Input: '([{}])'
Expected Output: True
Explanation: This is a properly nested sequence.
Input: '(]'
Expected Output: False
Explanation: The closing `]` does not match the opening `(`.
Input: '([)]'
Expected Output: False
Explanation: The counts match, but the nesting order is wrong.
Input: ''
Expected Output: True
Explanation: An empty string is considered balanced.
Hints
- Use a stack to remember opening brackets as you scan from left to right.
- When you see a closing bracket, it must match the most recent unmatched opening bracket.