Find Top Two Teams
Learn this problemProblem statement
Given 4 arrays wins, draws, scored, conceded of size N these arrays represent the stats of N teams. The array wins[i] represents the number of wins of the i'th team, draws[i] represents the number of draws of the i'th team, scored[i] represents the score of the i'th team, and conceded[i] represents the concede of the i'th team.
For every win, a team is rewarded 3 points and for every draw, a team is rewarded 1 point. The task is to find the highest and second-highest scoring teams. If there is a tie between the points, it will be resolved by taking the difference between scored[i] - conceded[i].
Return the indexes of the teams.
Function
findTopTwoTeams(wins: int[], draws: int[], scored: int[], conceded: int[]) → int[]
Complete the function findTopTwoTeams in the editor.
findTopTwoTeams has the following parameters:
int[] wins: an array of integers representing the number of winsint[] draws: an array of integers representing the number of drawsint[] scored: an array of integers representing the scoresint[] conceded: an array of integers representing the conceded scores
Returns
int[]: an array of two integers representing the indexes of the top two teams
Hello! Uber assessment comes with 4 coding questions. Here are the other 3 in the same batch 🥝 -
Examples
Example 1
wins = [1, 2, 3]draws = [1, 1, 1]scored = [10, 20, 30]conceded = [12, 23, 12]return = [2, 1]More Uber problems
- Last Truck to Leave the LaneOA · Seen Jul 2026
- Chain of CommandOA · Seen Jul 2026
- Jump Game with Prime-3 StepsOA · Seen Jun 2026
- Total Palindrome Substring CostOA · Seen Jun 2026
- Earliest Time All Users Are ConnectedPHONE SCREEN · Seen May 2026
- Tournament Rounds by RankPHONE SCREEN · Seen May 2026
- Farthest Seat AssignmentONSITE INTERVIEW · Seen May 2026
- Convex Function MinimizationPHONE SCREEN · Seen May 2026