This theory is part of Premium
The full write-up (worked counting examples, the trap list and the interview playbook) unlocks with a Premium plan, along with every Pro visualizer.
See pricingSweep from the right with a compressed Fenwick tree of seen values.
What this asks
For each element, count how many later elements are smaller.
Sweep from the right with a compressed Fenwick tree of seen values; the count below the rank is one prefix query.
The full write-up (worked counting examples, the trap list and the interview playbook) unlocks with a Premium plan, along with every Pro visualizer.
See pricing