FunctionRacerProblemsRace

Best Columns of Each Row

MediumNumPyPython

Return, for each row of scores, the column numbers of its k largest values, largest first. Among equal values the lower column comes first. No loops: for and while are not allowed.

Example 1

scores [[3,9,3,7],[5,5,1,5]]
k 2
returns [[1,3],[0,1]]

Row 0: 9 is in column 1, then 7 in column 3. Row 1: three 5s tie, and columns 0 and 1 come first.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More NumPy problems