FastPrepValidate a Simplified Mahjong Winning Hand
Problems/Validate a Simplified Mahjong Winning Hand

Validate a Simplified Mahjong Winning Hand

Google logoGoogle● MediumNEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report describes a Mahjong-like array of fourteen numbers and asks whether it is a winning hand. We chose the rank range, four melds plus one pair, triples and runs, a supply of four copies, leaving out special hands, the examples, and the signature, based on the usual simplified single-suit Mahjong task. Mahjong reports from other companies are related evidence, not copies of the Google report. Our version is about 76% the same as the reported question.

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[]) → boolean

Examples

Example 1

tiles = [1,1,1,2,3,4,2,3,4,7,8,9,5,5]return = true

Use 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 = true

Use 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 = false

No 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

Interview reports that mention this question

  • Google New Grad SWE Interview Questions Guide (Part 1 of 2)
  • Google PhD New Grad Five-Round Loop: 1 Experience
  • Google PhD AI/ML Onsite Mahjong and Prefix Search: 1 Experience

Google interview experiences

  • Google interviews · November 2026
  • Google Software Engineer Onsite Questions: 10 Experiences
  • Google OA: What It Tests (2026)
All Google interview questionsSee Google hiring insights
Saved
class Solution {
    public boolean isWinningMahjongHand(int[] tiles) {
        // write your code here
    }
}
Checking account…