So, I had an on-campus interview for round 2 of my Facebook interviews, and my interviewer decided to ask me this one question about the maximum number of vacation days.
The question is as follows:
Given a boolean array and a number, the number of paid-time off days (PTO), return the maximum number of vacation days you can take. Here, vacation means anything like holidays, weekends, etc.
So, “True” means work days, and “False” means days off (weekends, holidays, etc.), and you can take any work days as paid-time off days (PTO).
Input: [ F F T T F T F ] , PTO = 2
Output: maximum number of vacation days = 5, because you could make index 2 and index 3 your two PTO days, and you would get 5 consecutive vacation days/days off (i.e. F F F F F).
I thought it was a rather difficult question.