Back to problems

Longest Vacation With PTO (flip W to H)

Algorithm · Meta · Medium

Problem You receive a character array days with n entries describing one calendar year: 'H' denotes a holiday. 'W' denotes a workday. You may spend one of your PTO days on any 'W' entry, which lets that day count as vacation. Find the greatest number of adjacent days that can form one vacation. In other words, return the length of the longest contiguous subarray containing no more than PTO workdays. Example: days = [W, H, H, W, W, H, W], PTO = 2 -> 5 Input/Output Input: A…

Checking your access…