Validate parentheses and find k-th largest
Company: Meta
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Technical Screen
Quick Answer: This pair of problems evaluates mastery of fundamental data structures and algorithmic techniques: Problem A tests understanding of stack-based parsing and bracket-matching invariants for validating nested delimiters, while Problem B assesses proficiency with selection algorithms and heap-based priority queues for finding the k-th largest element.
Validate Parentheses
Constraints
- Inputs are Python literals matching the function signature.
- Return a deterministic exact-match value.
Examples
Input: ('()[]{}',)
Expected Output: True
Explanation: Valid mixed brackets.
Input: ('([)]',)
Expected Output: False
Explanation: Wrong nesting.
Input: ('(((',)
Expected Output: False
Explanation: Unclosed openings.
Hints
- Clarify edge cases before coding.
- Keep the return value deterministic.
Kth Largest Element
Constraints
- Inputs are Python literals matching the function signature.
- Return a deterministic exact-match value.
Examples
Input: ([3,2,1,5,6,4], 2)
Expected Output: 5
Explanation: Second largest is 5.
Input: ([3,2,3,1,2,4,5,5,6], 4)
Expected Output: 4
Explanation: Duplicates count separately.
Input: ([1], 1)
Expected Output: 1
Explanation: Single element is the first largest.
Hints
- Clarify edge cases before coding.
- Keep the return value deterministic.