Weak Characters in the Game

A band of adventurers is rehearsing a battle drill. Each adventurer is described by a pair of attributes only: attack attack[i] and defense defense[i]. For the drill to run, the party calculates who can dominate whom. Adventurer i is said to be weak if there exists some other adventurer j whose attack is strictly greater than attack[i] and whose defense is strictly greater than defense[i]. Being stronger in just one attribute is never enough, and two different adventurers with identical attributes cannot make each other weak.

Given an array properties where properties[i] = [attack[i], defense[i]], return the number of weak adventurers. Because the group can be large, the answer must be computed efficiently by ordering the adventurers cleverly rather than comparing every pair.

Examples
Input: [[5,5],[6,3],[3,6]]
Output: 0
Hints

Weak Characters in the Game

A band of adventurers is rehearsing a battle drill. Each adventurer is described by a pair of attributes only: attack `attack[i]` and defense `defense[i]`. For the drill to run, the party calculates who can dominate whom. Adventurer `i` is said to be **weak** if there exists some other adventurer `j` whose attack is **strictly greater** than `attack[i]` and whose defense is **strictly greater** than `defense[i]`. Being stronger in just one attribute is never enough, and two different adventurers with identical attributes cannot make each other weak.