Leetcode 962. Maximum Width Ramp
Find the maximum distance j - i (i < j) such that nums[i] <= nums[j] in the array โ i.e., the farthest valid "ramp". With n up to 5ยท10^4, brute force is too slow; this is typically solved with a monotonic decreasing stack or by sorting value-index pairs to achieve near-linear or n log n time.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
0
Hello Interview Premium
Your account is free and you can post anonymously if you choose.