⌘K
Flycodx

Ola Surge Pricing Window Detection

Ola Surge Pricing Window Detection

MediumArrays22% accepted

Ravi monitors surge pricing patterns for Ola in Delhi during peak hours. An array contains hourly fare multipliers. He needs to find all time windows where surge pricing (2.5x or higher) was active continuously for the longest duration.

Approach

Given an array of hourly fare multipliers and a surge threshold, find the length of the longest contiguous period where all multipliers are >= threshold.

Input

n=9 threshold=2.5 arr=[2.1,2.8,3.0,2.9,2.0,3.2,2.6,2.7,1.8]

Output

3
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