FunctionRacerProblemsRace

Most Races Won

EasyGreedyPython, JavaScript, TypeScript, Java, C++

mine lists the speeds of your horses and theirs the speeds of a rival's horses; both lists have the same length. The horses race in pairs: every horse, yours and theirs, runs in exactly one race, and you decide which of your horses meets which of theirs. You win a race only when your horse is strictly faster. Return the largest number of races you can win.

Example 1

mine [5,3,8]
theirs [4,6,2]
returns 3

Send 3 against 2, 5 against 4 and 8 against 6: all three races are won.

Example 2

mine [1,2,3]
theirs [3,3,3]
returns 0

None of your horses is faster than 3, so no race can be won.

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 Greedy problems