FastPrepDetermine Player Rankings
Problems/Determine Player Rankings

Determine Player Rankings

Google logoGoogle● MediumFULLTIMENEW GRADPHONE SCREENONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report asks for every player whose rank can be known for sure, and that rank. It uses forward reachability to weaker players plus reverse reachability to stronger ones. This exercise already had rules for contradictory cycles, duplicate results, and zero-based IDs. This fix keeps those rules and brings back the rank in the output. Our version is about 95% the same as the reported question.

There are n players indexed from 0 through n - 1, with unique strict ranks from 1 (strongest) through n (weakest). Each result [winner, loser] means the winner is stronger than the loser. Strength relationships are transitive.

A player's rank is determinable when, for every other player, exactly one of the two players can reach the other through transitive win results. If two players can reach each other because of contradictory cyclic results, that relation is not strict and neither direction may be used to establish determinability between those two players.

Return one row [player, rank] for every determinable player, ordered by increasing player index. A determinable player's rank is 1 + the number of players that can reach that player.

Function

determinablePlayerRanks(n: int, wins: int[][]) → int[][]

Examples

Example 1

n = 3wins = [[0,1],[1,2]]return = [[0,1],[1,2],[2,3]]

The chain determines every pair. Player 0 has no stronger player, player 1 has one, and player 2 has two.

Example 2

n = 3wins = [[0,1]]return = []

Every player has at least one unknown relation, so no exact rank can be established.

Example 3

n = 3wins = [[0,1],[1,0],[1,2]]return = [[2,3]]

Players 0 and 1 are mutually reachable and therefore not strictly ordered. Both reach player 2, whose relation to each other player is one-way, so player 2 is determinably third.

Constraints

  • 1 <= n <= 300.
  • 0 <= wins.length <= 100000.
  • Every result contains two distinct valid player indices.
  • Duplicate results may appear.

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

  • All Halfway Courses Across Course TracksCrunchyroll · PHONE SCREENCrunchyroll interview questions
  • Shortest Paths in a Nonnegative Directed GraphNation with NaMo · PHONE SCREEN
  • Minimum Traveling Salesperson TourGoldman Sachs · PHONE SCREENGoldman Sachs interview questions
  • Minimum Completion Time for DAG DependenciesAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Work Order Critical PathHadrian · PHONE SCREENHadrian interview questions
  • Longest Name Chain in a Directed Acyclic GraphOscar Health · PHONE SCREEN
  • Service Dependency Load FactorsRobinhood · PHONE SCREENRobinhood interview questions
  • Employee Hierarchy Cycle and Depth AnalysisMicrosoft · PHONE SCREENMicrosoft interview questions
  • Knight Dialer SequencesWhatNot · PHONE SCREENWhatNot interview questions
  • Minimum Time to Complete Target CoursesMeta · ONSITE INTERVIEWMeta interview questions

Interview reports that mention this question

  • Google New Grad R1, Player Rankings: 1 Experience

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
All Google interview questionsSee Google hiring insights
Saved
class Solution {
    public int[][] determinablePlayerRanks(int n, int[][] wins) {
        // write your code here
    }
}
Checking account…