#490 Counting Vacation Options Without Release Days

Companies:
T-Bank
Themes:
AlgorithmsArraysPractice

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

Mentor
Answer as you would in a real interview. I’ll ask follow-up questions, then compare your answer with the reference answer and show your accuracy as a %.
Sign in to start the dialogue The mentor keeps the context of the current question and your previous messages.
Sign in