links: [[Algorithms MOC]] --- # Problem A **ramp** in an integer array `nums` is a pair `(i, j)` for which `i < j` and `nums[i] <= nums[j]`. The **width** of such a ramp is `j - i`. Given an integer array `nums`, return _the maximum width of a **ramp** in_ `nums`. If there is no **ramp** in `nums`, return `0`. **Constraints:** - 2 <= nums.length <= 5 * $10^4$ - 0 <= nums[i] <= 5 * $10^4$ # Approach 1 Using two pointer approach. Right pointer expands the range and Left pointer contracts it. --- tags: #array #stack #monotonic-stack source: - [LeetCode Problem](https://leetcode.com/problems/maximum-width-ramp/)