Replace Each Element by Its Rank in C++

Replace Each Element by Its Rank in C++ (LeetCode 1331: Rank Transform of an Array) is a classic coordinate compression and sorting problem frequently featured in technical interviews at top software engineering firms including Amazon, Microsoft, Adobe, Bloomberg, and Google. Given an array of integers arr, the algorithmic objective is to replace each element with …