#490 Counting Vacation Options Without Release Days
Programmer Izosim wants to take a vacation lasting at least k consecutive days. Team lead Innokenty does not allow Izosim to go on vacation if a release is scheduled for any day of his absence.
The input contains k, the minimum vacation duration acceptable to Izosim, and a list of days represented as an array of 0 values, meaning no release, and 1 values, meaning a release is scheduled.
Find the number of possible vacation options, taking into account that the vacation must not be interrupted by working days.
findDayoffs(2, [0,0,1,0,0]) -> 2
findDayoffs(1, [0,0,1,0]) -> 4 // Three one-day options and one two-day option
findDayoffs(3, [0,0,1,0,0]) -> 0
Question review
Sign in to start the dialogue
The mentor keeps the context of the current question and your previous messages.
Sign in
Available with Premium
This is just one of the solutions available with Premium. And more:
- 250+ advanced lectures
- 1300+ practice exercises
- 500+ solutions to problems from real interviews
- Personalized Java Hub certificates
- Expanded access to the AI mentor