Find Top Two Teams
Updated
Problem statement
The arrays wins, draws, scored, and conceded describe the statistics of n teams. Team i earns 3 * wins[i] + draws[i] league points.
Return the indices of the highest-ranked and second-highest-ranked teams in that order. Rank the teams using these rules:
- More league points ranks higher.
- If points tie, a larger goal difference
scored[i] - conceded[i]ranks higher. - If both tie, the smaller team index ranks higher.
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]The teams earn 4, 7, and 10 league points. Team 2 ranks first and team 1 ranks second, so the result is [2, 1].
Constraints
2 <= n <= 100000.wins.length == draws.length == scored.length == conceded.length == n.0 <= wins[i], draws[i], scored[i], conceded[i] <= 10^9.
More Autodesk interview questions
- Diagonal Bounce TraversalOA · Seen Oct 2026
- Interleave Array HalvesOA · Seen Oct 2026
- Latest Arrival to Catch a BusOA · Seen Oct 2026
- In-Memory Database with TTLOA · Seen Mar 2026
- Non-Repeating CharacterONSITE INTERVIEW · Seen Nov 2026
- Remove Trailing ZerosONSITE INTERVIEW · Seen Nov 2026
- Reverse Linked ListONSITE INTERVIEW · Seen Nov 2026
- LRU Cache with TTLONSITE INTERVIEW · Seen Oct 2026
- Deep Merge with a Conflict ResolverONSITE INTERVIEW · Seen Mar 2026
Similar questions at other companies
- Macaron Order with Set DiscountsShopify · OAShopify interview questions
- Build the Task HierarchyPendo · OA
- 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