PracHub
QuestionsCoachesLearningGuidesInterview Prep

Quick 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.

  • Medium
  • Meta
  • Coding & Algorithms
  • Software Engineer

Maximize vacation streak with PTO

Company: Meta

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Technical Screen

##### Question Given an array of characters containing 'w' (workday) and 'h' (holiday) and an integer n representing the number of PTO days you can convert from workdays, design an algorithm to find the maximum possible length of consecutive days off (holidays plus converted PTO days). Explain the time and space complexity and outline a sliding-window solution.

Quick Answer: 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.

You are given a string days consisting only of 'h' (holiday) and 'w' (workday), and an integer n representing how many workdays you can convert to holidays (PTO). Return the maximum possible length of a contiguous block of days off after converting at most n 'w' characters to 'h'.

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

  1. Think in terms of the longest window containing at most n workdays.
  2. Maintain a sliding window with two pointers and a count of 'w' inside it.
  3. When the count of 'w' exceeds n, move the left pointer to shrink the window until it is valid again.
Last updated: Mar 29, 2026

Loading coding console...

PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • AI Coding Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.

Related Coding Questions

  • Find Shortest Unique Prefixes - Meta (medium)
  • Compute Exclusive Execution Times - Meta (medium)
  • Solve Tree Columns And Maze Variants - Meta (medium)
  • Solve Tree Diameter and Palindromic Counts - Meta (medium)
  • Simulate Monster Team Battles - Meta (hard)