Beautiful Pairs
Treat each index as a point and sweep left to right; two Fenwick trees find the nearest Manhattan partner below and above each point.
Treat each index as a point and sweep left to right; two Fenwick trees find the nearest Manhattan partner below and above each point.