FastPrepFastPrep
Problem Brief

Find Top Two Teams

FULLTIMEOA
See Uber online assessment and hiring insights

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 Description

Complete the function findTopTwoTeams in the editor.

findTopTwoTeams has the following parameters:

  1. int[] wins: an array of integers representing the number of wins
  2. int[] draws: an array of integers representing the number of draws
  3. int[] scored: an array of integers representing the scores
  4. int[] 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 🥝 -

1Example 1

Input
wins = [1, 2, 3], draws = [1, 1, 1], scored = [10, 20, 30], conceded = [12, 23, 12]
Output
[2, 1]
Explanation
points for team 0 = 13 + 11 = 4 points for team 1 = 23 + 11 = 7 points for team 2 = 33 + 11 = 10 return {2,1} PPS: if there is a tie between teams points it will be resolved by taking the difference bewteen scored[i] - conceded[i]
public int[] findTopTwoTeams(int[] wins, int[] draws, int[] scored, int[] conceded) {
  // write your code here
}
Input

wins

[1, 2, 3]

draws

[1, 1, 1]

scored

[10, 20, 30]

conceded

[12, 23, 12]

Output

[2, 1]

Sign in to submit your solution.