Maximize vacation streak with PTO
Company: Meta
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Technical Screen
Overview: This question evaluates proficiency in algorithmic problem-solving with arrays, specifically reasoning about consecutive subarray computations, linear-time scanning techniques, and the ability to analyze time and space complexity.
Constraints
- 0 <= len(days) <= 200000
- days[i] is either 'h' or 'w'
- 0 <= n <= len(days)
- Return 0 if days is empty
- Answer is in the range [0, len(days)]
Hints
- Think in terms of the longest window containing at most n workdays.
- Maintain a sliding window with two pointers and a count of 'w' inside it.
- When the count of 'w' exceeds n, move the left pointer to shrink the window until it is valid again.