Determine if a 14-tile hand is winning
Company: Google
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Technical Screen
Quick Answer: This Coding & Algorithms question evaluates algorithmic reasoning about combinatorial search and multiset partitioning, testing the candidate's ability to represent and manipulate tile counts and validate pattern-based groupings.
Constraints
- `tiles.length == 14`
- `1 <= tiles[i] <= 9`
- Tiles may contain duplicates
Examples
Input: ([1,1,1,2,3,4,2,3,4,5,6,7,9,9],)
Expected Output: True
Explanation: A valid partition is pair `9,9`, triplet `1,1,1`, sequence `2,3,4`, sequence `2,3,4`, and sequence `5,6,7`.
Input: ([2,2,2,3,3,3,4,4,4,5,5,5,9,9],)
Expected Output: True
Explanation: Use pair `9,9` and four triplets: `2,2,2`, `3,3,3`, `4,4,4`, `5,5,5`.
Input: ([1,1,2,2,3,3,4,5,5,5,6,7,8,9],)
Expected Output: True
Explanation: The correct pair is `5,5`. The remaining tiles form sequences `1,2,3`, `1,2,3`, `4,5,6`, and `7,8,9`.
Input: ([1,1,1,1,2,3,4,5,6,7,8,8,9,9],)
Expected Output: False
Explanation: No matter which pair you choose, the remaining 12 tiles cannot be fully split into four valid triplets/sequences. This case heavily uses boundary values 1 and 9.