Competition Winner and Runner-Up (Forward Deployed Engineer)
Updated
Problem statement
Given four arrays wins, draws, scored and conceded that describe the teams in a competition, return the indices of the winning team and the team in second place as [winner, secondPlace].
Team i won wins[i] matches, tied draws[i] matches, scored scored[i] goals and conceded conceded[i] goals, for each i from 0 to wins.length - 1. A won match gives a team 3 points, a tied match gives 1 point, and a lost match gives 0 points.
The team with the most points ranks first. When teams have the same number of points, the one with the higher goal difference ranks higher. The goal difference of team i is scored[i] - conceded[i].
Note: a solution with time complexity no worse than O(wins.length^3) is fast enough.
Function
solution(wins: int[], draws: int[], scored: int[], conceded: int[]) → int[]Examples
Example 1
wins = [2,1,3]draws = [1,4,0]scored = [5,6,4]conceded = [3,2,6]return = [2,1]The teams have 7, 7 and 9 points. Team 2 has the most points, so it wins. Teams 0 and 1 tie on 7 points. Team 1 has the higher goal difference, 4 against 2, so it is second.
Example 2
wins = [2,2,1]draws = [1,1,2]scored = [3,8,5]conceded = [4,2,5]return = [1,0]Teams 0 and 1 both have 7 points. Team 1 has a goal difference of 6 and team 0 has -1, so team 1 wins and team 0 is second. Team 2 has a better goal difference than team 0, but only 5 points.
Example 3
wins = [3,0,2]draws = [0,10,1]scored = [9,1,4]conceded = [0,1,3]return = [1,0]Team 1 never won a match, but its 10 draws give it 10 points. That is more than team 0, which has 9 points from 3 wins. Team 2 has 7 points.
Constraints
2 <= wins.length <= 100draws.length == scored.length == conceded.length == wins.length0 <= wins[i], draws[i], scored[i], conceded[i] <= 1000- Exactly one team ranks first and exactly one team ranks second. No other team has both the same points and the same goal difference as the winner, and the same holds for the team in second place.
More Boston Consulting Group interview questions
- Build Taxi Driver Performance FeaturesOA · Seen Nov 2026
- Summarize Taxi Drivers and RidesOA · Seen Nov 2026
- Count Belt Sections With K Fruit Pairs (Forward Deployed Engineer)OA · Seen Nov 2026
- Robot Stops Left or Right (Forward Deployed Engineer)OA · Seen Nov 2026
- Split a Matrix Into Four Partitions by Average (Forward Deployed Engineer)OA · Seen Nov 2026
- Predict Taxi Driver ClassesOA · Seen Oct 2026
- Prepare Taxi Driver Classification DataOA · Seen Oct 2026
- Even-Position MonotonicityOA · Seen Jul 2026
- Shortest Distances From an Adjacency MatrixPHONE SCREEN · Seen Sep 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
- 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
- Total Server DowntimeVisa · OAVisa interview questions