⌘K
Flycodx

Dunzo Delivery Route Max Width Ramp

Dunzo Delivery Route Max Width Ramp

HardStacks0% accepted

Dunzo encodes route priorities as integers. A ramp is a pair (i, j) where i < j and nums[i] <= nums[j]. Find the maximum width j - i of any such ramp.

Approach

Maximum width ramp in array: largest j-i where i<j and nums[i]<=nums[j].

Input

6 6 0 8 2 1 5

Output

4
solution.py
Loading editor...
Test 1
Test 2
Test 3

Press Run to test your custom input, or Submit to judge against all test cases.

Sign in to continue

Create a free account to run code, submit solutions and track progress.

  • Free forever — no credit card
  • 10+ languages with live execution
  • Points, streaks & leaderboards
Auto Save OnLn 1, Col 1Spaces: 4UTF-8LFPython 3