FastPrepRank Football Teams
Problems/Rank Football Teams

Rank Football Teams

Capital One logoCapital One● EasyFULLTIMEOA
QuestionFunctionExamplesConstraints

Problem statement

Source note: The visible report supplies the four parallel arrays, points formula, goal-difference comparison, suggested goals-scored tie-break, top-two index result, and illustrative tuple-sort code. The judged core capability matches the report at about 90%; the final complete-tie rule and cross-language bounds are explicit practice assumptions.

Special thanks: 🌷 A special thank you to a lovely, amazing fren who shared that this question appeared again on October 31, 2026! ( ˘͈ ᵕ ˘͈♡) 🩷

You are given four parallel arrays, wins, draws, scored, and conceded. Index i identifies one football team.

Team i earns 3 * wins[i] + draws[i] points and has goal difference scored[i] - conceded[i].

Rank all teams using these keys, in order:

  1. More points ranks first.
  2. If points are equal, larger goal difference ranks first.
  3. If goal difference is also equal, more goals scored ranks first.
  4. If all three statistics are equal, the smaller original team index ranks first.

Return a two-element array containing the original indices of the first- and second-ranked teams, in that order.

Function

rankTeams(wins: int[], draws: int[], scored: int[], conceded: int[]) → int[]

Examples

Example 1

wins = [3,2,3]draws = [0,4,0]scored = [8,10,7]conceded = [3,4,1]return = [1,2]

Team 1 has 10 points, while teams 0 and 2 each have 9. Team 2 has goal difference 6, ahead of team 0 with goal difference 5, so the top two indices are [1,2].

Example 2

wins = [2,2,2,2]draws = [1,1,1,1]scored = [5,6,6,6]conceded = [2,4,3,3]return = [2,3]

Every team has 7 points. Teams 0, 2, and 3 have the best goal difference, 3. Teams 2 and 3 then lead on goals scored, and their complete tie is resolved by smaller index, so they rank first and second.

Example 3

wins = [0,1]draws = [4,0]scored = [2,10]conceded = [0,0]return = [0,1]

Team 0 has 4 points and team 1 has 3. Points are compared before goal difference or goals scored, so team 0 ranks first.

Constraints

  • 2 ≤ wins.length ≤ 10^5.
  • draws.length = scored.length = conceded.length = wins.length.
  • 0 ≤ wins[i], draws[i], scored[i], conceded[i] ≤ 10^9.
  • Use a wide enough integer type when computing points and goal difference.

More Capital One problems

  • Digit-Coded Card ValidationONSITE INTERVIEW · Seen Nov 2026
  • Count Subarrays Matching a Comparison PatternOA · Seen Oct 2026
  • Arithmetic Triplets After QueriesOA · Seen Oct 2026
All Capital One interview questionsSee Capital One hiring insights
Saved
public int[] rankTeams(int[] wins, int[] draws, int[] scored, int[] conceded) {
    // write your code here
}
Checking account…