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
More Arrays problems
Browse all coding problems →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