Skip to content
DeepForgeby svx
All problems

League Matchmaking Pair

Problem

Find the pair of league players with the closest Elo ratings.

Return [i, j] with i < j minimizing |ratings[i] - ratings[j]|, breaking ties by the lexicographically smallest pair. Fewer than two players returns [-1, -1].

Hint

A strict comparison keeps the first pair found when several pairs tie.

Test cases

case 1
in: [[1500,1620,1615,1800]]
expected: [1,2]
case 2
in: [[1000,1200,1400,1600]]
expected: [0,1]
case 3
in: [[1500]]
expected: [-1,-1]
case 4
in: [[1500,1500]]
expected: [0,1]
Starter codePython
def league_matchmaking_pair(ratings):
    # Your code here
    pass

4 test cases · run your code against them in the editor