Tap here to switch tabs
Problem
Submissions

Problem: Maximum Width Ramp

Maximum Width Ramp asks you to find the greatest distance between two indices in an integer array where the earlier value is no greater than the later value, or return zero if none qualifies.

Statement

A ramp in an integer array nums is defined as a pair of indices (i, j) such that i < j and nums[i] <= nums[j]. The width of such a ramp is j - i.

Given an integer array nums, find and return the maximum width of any ramp in nums. If no valid ramp exists, return 00.

Constraints:

  • 2≤2 \leq nums.length ≤5×104\leq 5 \times 10^4

  • 0≤0 \leq nums[i] ≤5×104\leq 5 \times 10^4

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Width Ramp

Maximum Width Ramp asks you to find the greatest distance between two indices in an integer array where the earlier value is no greater than the later value, or return zero if none qualifies.

Statement

A ramp in an integer array nums is defined as a pair of indices (i, j) such that i < j and nums[i] <= nums[j]. The width of such a ramp is j - i.

Given an integer array nums, find and return the maximum width of any ramp in nums. If no valid ramp exists, return 00.

Constraints:

  • 2≤2 \leq nums.length ≤5×104\leq 5 \times 10^4

  • 0≤0 \leq nums[i] ≤5×104\leq 5 \times 10^4