FastPrepMaximize the Chance of Selecting the Best Candidate
Problems/Maximize the Chance of Selecting the Best Candidate

Maximize the Chance of Selecting the Best Candidate

Google logoGoogle● EasyFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The reported puzzle gives a top-four selector, a worst-of-subset selector, and one call to each. We made some choices: the returned count is general, the subset is fixed and chosen without rank information, and the answer is a reduced exact fraction. Our version is about 86% the same as the reported question.

A ranking service returns the topCount best candidates, but not their internal order. You may choose any subset of at least two returned candidates and call a second service once; it identifies the worst candidate in that subset.

After discarding the identified worst candidate, choose one of the remaining subset members uniformly at random. Return the maximum possible probability of selecting the overall best candidate as a reduced fraction [numerator, denominator].

Function

maxSuccessFraction(topCount: int) → int[]

Examples

Example 1

topCount = 4return = [1,2]

Choose any two candidates. The best candidate is in that pair with probability 2/4, and the worst-selector then leaves it as the only choice.

Example 2

topCount = 5return = [2,5]

A two-candidate subset succeeds with probability 2/5.

Constraints

  • 2 <= topCount <= 1000000000.
  • All returned candidates are distinct and have a strict total ranking.
  • The subset is chosen without knowing the internal ranking.

Source note: Author-written prompt excerpt retained for source fidelity.

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

  • Maximum 69 NumberHSBC · ONSITE INTERVIEWHSBC interview questions
  • Fewest Bills and CoinsCapital One · ONSITE INTERVIEWCapital One interview questions
  • Spend a Budget Across Five Price TiersExpedia · ONSITE INTERVIEWExpedia interview questions
  • Integer BreakAmazon · ONSITE INTERVIEW
  • Maximum Bananas Delivered by a CamelStackAdapt · ONSITE INTERVIEWStackAdapt interview questions
  • UCB1 Multi-Armed Bandit TraceWayfair · ONSITE INTERVIEWWayfair interview questions
  • Reach a Target by Adding CoordinatesJP Morgan Chase · ONSITE INTERVIEWJP Morgan Chase interview questions
  • Server InvestmentRippling · OARippling interview questions
  • Maximum Three-Server Difficulty ScoreVisa · OAVisa interview questions
  • Particle Moves to TargetCresta · OACresta interview questions

Google interview experiences

  • Google interviews · November 2026
  • Google Software Engineer Onsite Questions: 10 Experiences
  • Google OA: What It Tests (2026)
  • Google L4 SWE Phone Screen: 1 Experience
  • Google ML Engineering Manager Onsite: 1 Experience
  • Google Experienced SWE First Round and Onsite: 1 Experience
All Google interview questionsSee Google hiring insights
Saved
class Solution {
    public int[] maxSuccessFraction(int topCount) {
        // Write your code here.
    }
}
Checking account…