Count of Smaller Numbers After Self
HardLeetCodeSegment Tree & Fenwick Tree
Approach hintTry it first, then revealHide
Compress values to ranks and scan from the right. Before inserting the current rank into a Fenwick tree, query how many strictly smaller ranks are already present. O(n log n).