← Meta Interview Insights

Meta·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

Meta coding screen for a software engineer role. One algorithmic problem, sliding window style. Nothing crazy but I fumbled the complexity explanation more than I'd like to admit.

Questions Asked (1)

Q1

You're given an array of characters where each element is either 'w' (workday) or 'h' (holiday), and an integer n representing how many workdays you can convert to days off. Find the maximum number of consecutive days off you can get. Walk through your approach, the time and space complexity, and how a sliding window fits here.

Algorithms & Data Structures
Author's notes

I got the core idea pretty fast.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Use a sliding window to find the longest subarray with at most n 'w's. Expand the right pointer, count workdays, and shrink from the left when the count exceeds n. Track the maximum window length.

Pro tip: Clarify that 'consecutive days off' means consecutive days in the array where you either already have a holiday or convert a workday to a holiday. Mention that the window can include both 'h' and converted 'w's.

1. Clarify the problem

Confirm that you can convert at most n workdays to holidays, and you want the longest contiguous segment of days that are all holidays (original or converted).

2. Identify the sliding window pattern

Recognize that the problem reduces to finding the longest subarray with at most n 'w's. The window represents a candidate segment of consecutive days off.

3. Implement the sliding window

Initialize left and right pointers at 0, a workday count, and max length. Expand right, increment workday count if the character is 'w'. While workday count > n, shrink from left (decrement count if left character is 'w') and increment left. Update max length with right - left + 1.

4. Analyze complexity

Time complexity is O(m) where m is the array length, since each element is visited at most twice. Space complexity is O(1) as only a few variables are used.

5. Test with examples

Walk through a small example, e.g., ['w','h','w','w','h'] with n=1, to verify the window expands and shrinks correctly and returns the expected maximum.

Key Points to Mention

  • Sliding window technique for longest subarray with at most n workdays
  • Two-pointer approach with left and right indices
  • Time complexity O(m) and space complexity O(1)
  • Handling edge cases: n=0, n >= total workdays, empty array
  • The window can include both 'h' and converted 'w's
  • Tracking the maximum window length during expansion

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.