Beauty Values From Subarray Selections
Asked at Amazon · Coding Questions · Difficulty: Medium
Build a "beautiful array" by appending, for each pair `[l, r]`, the elements `arr[l..r]`. An index of `arr` is *used* if it lies in any pair's range. Return the sum, over every **unused** index `i`, of the count of values in the beautiful array that are strictly less than `arr[i]`.
Loading the problem…