⌘K
Flycodx

Consecutive Hotel Rooms Availability

Consecutive Hotel Rooms Availability

MediumArrays100% accepted

Arjun manages a luxury hotel in Mumbai. Rooms are booked for various dates, creating gaps of availability. He needs to find the longest stretch of consecutive empty rooms to accommodate a large wedding party.

Approach

Given an array where 1 represents booked and 0 represents available rooms, find the length of the longest consecutive sequence of available rooms.

Input

12 1 0 0 0 1 0 0 1 0 0 0 0

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