Solve tree view and parentheses cleanup
Company: Meta
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Technical Screen
Quick Answer: This question evaluates binary tree traversal and view-extraction skills for the right-side view problem and string-processing and minimal-edit balancing for the parentheses cleanup, probing competency in data-structure traversal, state tracking, and correctness under edge cases.
Right-Side View of a Binary Tree
Constraints
- Inputs are Python literals matching the function signature.
- Return a deterministic exact-match value.
Examples
Input: ([1,2,3,None,5,None,4],)
Expected Output: [1, 3, 4]
Explanation: Prompt example.
Input: ([],)
Expected Output: []
Explanation: Empty tree.
Hints
- Model object-style prompts as arrays or operation streams when needed.
- Handle empty and boundary cases before the main logic.
Remove Minimum Invalid Parentheses
Constraints
- Inputs are Python literals matching the function signature.
- Return a deterministic exact-match value.
Examples
Input: ('a)b(c)d',)
Expected Output: 'ab(c)d'
Explanation: Prompt example.
Input: ('))((',)
Expected Output: ''
Explanation: Remove all invalid parens.
Hints
- Model object-style prompts as arrays or operation streams when needed.
- Handle empty and boundary cases before the main logic.