Search
⌘K

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.

Comments

Your account is free and you can post anonymously if you choose.