heroes where heroes[i] = [attack, defense] describes hero i.
A hero is outclassed if some other hero has both a strictly higher attack and a strictly higher defense. Being ahead on just one stat is not enough.
Return the number of outclassed heroes.heroes=[[4, 7], [2, 3], [5, 2], [3, 6]] → 2
Hero [4, 7] beats both [2, 3] and [3, 6] on both stats. [5, 2] has the highest attack, and nobody has more defense than [4, 7]. So the answer is 2.
heroes=[[3, 3], [3, 5], [2, 4]] → 1
[2, 4] loses to [3, 5]. The two heroes with attack 3 do not outclass each other: both stats must be strictly higher.
heroes=[[4, 7], [2, 3], [5, 2], [3, 6]]
2
Run checks the first 3 tests in your browser. Submit checks all 101 tests on the server, hidden ones included.