Solve grid path and top‑k frequency
Company: Meta
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: Medium
Interview Round: Technical Screen
Quick Answer: This question evaluates algorithmic problem-solving in grid reachability and frequency analysis, testing concepts such as grid/graph traversal and obstacle handling for path existence alongside frequency counting and selection for top-k elements.
Grid Reachability With Obstacles
Constraints
- Inputs are Python literals matching the function signature.
- Return a deterministic exact-match value.
Examples
Input: ([[0,0],[1,0]],)
Expected Output: True
Explanation: Path exists.
Input: ([[0,1],[1,0]],)
Expected Output: False
Explanation: No path through obstacles.
Hints
- Clarify edge cases before coding.
- Keep the return value deterministic.
Top K Frequent Numbers
Constraints
- Inputs are Python literals matching the function signature.
- Return a deterministic exact-match value.
Examples
Input: ([1,1,1,2,2,3], 2)
Expected Output: [1, 2]
Explanation: Return top two by frequency.
Input: ([4,4,5,5,6], 2)
Expected Output: [4, 5]
Explanation: Ties are broken by numeric value for deterministic output.
Hints
- Clarify edge cases before coding.
- Keep the return value deterministic.