Algorithm · Waymo · Hard
A line of people stands in a queue, and their heights are given in the array heights, listed from the person at the front of the queue to the person at the back. All heights are distinct positive integers. Person i is able to see a person j standing behind them (that is, j > i) exactly when everyone positioned strictly between i and j is shorter than both person i and person j. Return an array answer of the same length, where answer[i] is how many people to the right of…