FastPrepCount Determinable Player Rankings
Problems/Count Determinable Player Rankings

Count Determinable Player Rankings

Google logoGoogle● MediumINTERNONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report gives match results as directed edges. A player's win or loss carries on through the players they beat or lost to. You count the players whose rank is fully known. The report does not say how players are named, how to treat repeated results, what to do with contradictory cycles, the input limits, or a function signature. We added those. Our version is about 94% the same as the reported question.

There are n players labeled from 0 through n - 1. Each row wins[i] = [winner, loser] records that winner defeated loser.

Results are transitive: if player A defeated player B, and player B defeated player C, then A ranks above C.

A player's strict rank is determinable when, for every other player, exactly one of these facts is inferable:

  • The player ranks above the other player.
  • The other player ranks above the player.

If both directions are reachable because of a contradictory cycle, that pair does not establish a strict ordering. Return the number of players whose strict rank is determinable.

Function

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

Examples

Example 1

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

Transitivity establishes 0 > 1 > 2, so every player's relation to both others is known in exactly one direction.

Example 2

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

Player 0 is above everyone and player 3 is below everyone. Players 1 and 2 are incomparable.

Example 3

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

Every player has at least one unknown relation involving player 2.

Example 4

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

Players 0 and 1 form a contradictory cycle, so neither has a strict rank. Player 2 is below both and is determinable.

Constraints

  • 1 <= n <= 300.
  • 0 <= wins.length <= n * (n - 1).
  • Every row in wins contains two valid, distinct player indices.
  • The same directed result may appear more than once and has the same effect as one occurrence.
  • Contradictory cycles may occur.

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

  • Minimum Completion Time for DAG DependenciesAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Minimum Time to Complete Target CoursesMeta · ONSITE INTERVIEWMeta interview questions
  • Cheapest Flights Within K StopsGoldman Sachs · ONSITE INTERVIEWGoldman Sachs interview questions
  • Critical Path Through Dependent TasksModular · PHONE SCREEN · ONSITE INTERVIEW
  • Rocket Component CostSpaceX · ONSITE INTERVIEWSpaceX interview questions
  • Knight Dialer SequencesBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • All-Pairs Shortest PathsMorgan Stanley · OA · ONSITE INTERVIEWMorgan Stanley interview questions
  • Distance Sums to Special Nodes in a Weighted TreeNutanix · ONSITE INTERVIEWNutanix interview questions
  • Knight Dialer SequencesConfluent · ONSITE INTERVIEWConfluent interview questions
  • Parallel Courses IIISnowflake · ONSITE INTERVIEWSnowflake 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 countDeterminablePlayers(int n, int[][] wins) {
        // Return how many players have a strict relation to every other player.
    }
}
Checking account…