Solve matrix add, frequency count, longest consecutive
Company: Disney
Role: Data Scientist
Category: Coding & Algorithms
Difficulty: Medium
Interview Round: Technical Screen
Quick Answer: This question evaluates proficiency in basic numerical and array operations (matrix addition), associative data structures for frequency counting (hash maps), and set-based algorithmic reasoning for the longest consecutive sequence problem.
Add Two Matrices
Constraints
- Inputs are Python literals matching the function signature.
- Return a deterministic exact-match value.
Examples
Input: ([[1,2],[3,4]], [[5,6],[7,8]])
Expected Output: [[6, 8], [10, 12]]
Explanation: Add corresponding entries.
Input: ([], [])
Expected Output: []
Explanation: Empty matrices return empty output.
Hints
- Clarify edge cases before coding.
- Keep outputs deterministic when several valid answers exist.
Count Name Occurrences
Constraints
- Inputs are Python literals matching the function signature.
- Return a deterministic exact-match value.
Examples
Input: (["Amy","Bob","Amy"],)
Expected Output: {'Amy': 2, 'Bob': 1}
Explanation: Amy appears twice.
Input: ([],)
Expected Output: {}
Explanation: No names means no counts.
Hints
- Clarify edge cases before coding.
- Keep outputs deterministic when several valid answers exist.
Longest Consecutive Sequence
Constraints
- Inputs are Python literals matching the function signature.
- Return a deterministic exact-match value.
Examples
Input: ([100,4,200,1,3,2],)
Expected Output: 4
Explanation: The longest run is 1,2,3,4.
Input: ([0,3,7,2,5,8,4,6,0,1],)
Expected Output: 9
Explanation: The longest run is 0 through 8.
Input: ([],)
Expected Output: 0
Explanation: Empty input has run length zero.
Hints
- Clarify edge cases before coding.
- Keep outputs deterministic when several valid answers exist.