FastPrepFind Top Two Teams
Problems/Find Top Two Teams

Find Top Two Teams

Uber logoUber● EasyFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

There are N teams. For team i (counted from 0), wins[i] is its number of wins and draws[i] is its number of draws. scored[i] is the number of goals it scored, and conceded[i] is the number of goals scored against it.

A win is worth 3 points and a draw is worth 1 point. Rank the teams by points, highest first. If two teams have the same points, the team with the larger scored[i] - conceded[i] ranks higher. If they are still tied, the team with the smaller index ranks higher.

Return the indexes of the best team and the second best team, in that order.

Complete the function findTopTwoTeams in the editor.

findTopTwoTeams has the following parameters:

  • int[] wins: the number of wins of each team
  • int[] draws: the number of draws of each team
  • int[] scored: the goals scored by each team
  • int[] conceded: the goals conceded by each team

The function returns an int[] with two integers: the index of the best team, then the index of the second best team.

Function

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

Examples

Example 1

wins = [1, 2, 3]draws = [1, 1, 1]scored = [10, 20, 30]conceded = [12, 23, 12]return = [2, 1]

Team 0 has 1 * 3 + 1 * 1 = 4 points. Team 1 has 2 * 3 + 1 * 1 = 7 points. Team 2 has 3 * 3 + 1 * 1 = 10 points. The best team is team 2 and the second best is team 1, so the answer is [2, 1]. No team has the same points as another, so the goal difference is not needed here.

Constraints

  • 2 ≤ N ≤ 105
  • wins.length = draws.length = scored.length = conceded.length = N
  • 0 ≤ wins[i], draws[i] ≤ 104
  • 0 ≤ scored[i], conceded[i] ≤ 109

More Uber interview questions

  • Worst-Performing Ads by CTR in a Campaign TreePHONE SCREEN · Seen Nov 2026
  • Earliest Time All Users Are ConnectedPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Max Points on a LinePHONE SCREEN · Seen Oct 2026
  • Online Meeting Scheduler with Fixed RoomsONSITE INTERVIEW · Seen Oct 2026
  • Convex Function MinimizationPHONE SCREEN · Seen Oct 2026
  • Meeting Rooms IIPHONE SCREEN · Seen Oct 2026
  • Merge Meeting IntervalsPHONE SCREEN · Seen Oct 2026
  • Minimum Meeting Rooms with AssignmentsPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Serialize and Deserialize an N-Ary TreeONSITE INTERVIEW · Seen Oct 2026
  • Find Robots by Blocker DistancesPHONE SCREEN · Seen Oct 2026

Similar questions at other companies

  • Count User Mentions in Chat MessagesRamp · OARamp interview questions
  • Catch Fish with Reusable BaitsSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
  • Competition Winner and Runner-Up (Forward Deployed Engineer)Boston Consulting Group · OABoston Consulting Group interview questions
  • Word Frequency Counts in Alphabetical OrderAbridge · OAAbridge interview questions
  • Rank Football TeamsCapital One · OACapital One interview questions
  • Maximum Apples That Fit in a BoxVirtu Financial · OAVirtu Financial interview questions
  • Rank Football TeamsPersona · OAPersona interview questions
  • Meandering ArrayVerisk · OA
  • Minimum Magic Stones After MergesElevenLabs · OAElevenLabs interview questions
  • Find Top Two TeamsAutodesk · OAAutodesk interview questions
All Uber interview questionsSee Uber hiring insights
Saved
class Solution {
    public int[] findTopTwoTeams(int[] wins, int[] draws, int[] scored, int[] conceded) {
      // write your code here
    }

}
Checking account…