279. Partition Around a Value
Given n integers and a pivot value p, print three numbers separated by
spaces: how many values are less than p, how many equal it, and how many are
greater.
That three-way split is the partition step at the heart of quicksort, and counting it first is the easiest way to understand what quicksort is doing before writing the version that rearranges the array in place.
The pivot need not appear in the array at all, in which case the middle count is 0.
Constraints - `1 ≤ n ≤ 200000` - `-1000000000 ≤ p ≤ 1000000000` - `-1000000000 ≤ a[i] ≤ 1000000000`
Input
The first line contains two integers n and p.
The second line contains n integers.
Output
Print three integers separated by spaces: the counts less than, equal to, and greater than p.
Hints
Four rungs, in order. The last two open once you have submitted an attempt. A wrong one counts.