Validate a Simplified Mahjong Winning Hand
Updated
Problem statement
tiles contains exactly fourteen tile ranks from 1 through 9. A winning hand can be partitioned into exactly four melds and one pair.
- A pair is two equal ranks.
- A meld is either three equal ranks or three consecutive ranks.
Every tile occurrence must be used exactly once. Return whether the hand is winning. Special Mahjong hands are not included.
Function
isWinningMahjongHand(tiles: int[]) → booleanExamples
Example 1
tiles = [1,1,1,2,3,4,2,3,4,7,8,9,5,5]return = trueUse triple 111, runs 234, 234, and 789, plus pair 55.
Example 2
tiles = [1,1,2,2,3,3,4,4,5,5,6,6,7,7]return = trueUse pair 11 and runs 234, 234, 567, and 567.
Example 3
tiles = [1,1,1,2,2,2,3,3,3,4,4,5,6,9]return = falseNo choice of pair lets all remaining tiles form four complete melds.
Constraints
tiles.length == 14.1 <= tiles[i] <= 9.- No rank appears more than four times.
More Google Onsite Interview questions
- Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Distinct Subset SumsONSITE INTERVIEW · Seen Nov 2026
- Playlist With No Same Artist in a RowONSITE INTERVIEW · Seen Nov 2026
- Delete Nodes and Return Forest RootsONSITE INTERVIEW · Seen Nov 2026
- Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- First and Last Target Position in a Mountain ArrayONSITE INTERVIEW · Seen Nov 2026
- Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- 0/1 Knapsack with Weight and Volume LimitsONSITE INTERVIEW · Seen Nov 2026
- Batched Subsequence Word MatchesONSITE INTERVIEW · Seen Nov 2026
Similar questions at other companies
- Generate All Permutations of a NumberFleetx · ONSITE INTERVIEW
- Unique Single-Use Sum CombinationsLinkedIn · ONSITE INTERVIEWLinkedIn interview questions
- Bounded Combination Sum with Signed CandidatesConfluent · ONSITE INTERVIEWConfluent interview questions
- Spaceship Equipment LoadoutJane Street · ONSITE INTERVIEWJane Street interview questions
- Insert Addition and Multiplication OperatorsPinterest · ONSITE INTERVIEWPinterest interview questions
- Enumerate Character Paths to a MarkerTesla · ONSITE INTERVIEWTesla interview questions
- Maximum Unique-Character Word SubsetMeta · ONSITE INTERVIEWMeta interview questions
- Subsets IIBloomberg LP · ONSITE INTERVIEWBloomberg LP interview questions
- Generate Circular Student ArrangementsAmazon · ONSITE INTERVIEW
- Combination Sum With Unlimited ReuseMicrosoft · ONSITE INTERVIEWMicrosoft interview questions