← Google Interview Insights

Google·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

Google SWE coding round, pretty focused on array problems. The base question was straightforward but the follow-up with the replacement twist is where things got interesting and honestly where I think most people slip up.

Questions Asked (1)

Q1

Given an integer array, find the length of the longest strictly increasing contiguous subarray. Then, as a follow-up: if you can replace at most one element anywhere in the subarray, what is the longest increasing subarray you can achieve?

Algorithms & Data Structures
Author's notes

The base case is fine, just a sliding window.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the problem and edge cases, then present a linear-time sliding window solution for the base case. For the follow-up, extend the approach by tracking the length of increasing runs and considering replacements at boundaries, aiming for an O(n) solution.

Pro tip: Explicitly state the time and space complexity of your solution and discuss potential optimizations or alternative approaches, showing you think beyond the immediate problem.

1. Clarify the problem

Ask clarifying questions about input constraints, definition of 'strictly increasing', and whether the replacement can be any integer. Confirm that the subarray must be contiguous.

2. Base case solution

Explain a sliding window or two-pointer approach to find the longest strictly increasing contiguous subarray in O(n) time. Track the start of the current increasing run and update the maximum length.

3. Follow-up analysis

For the follow-up, consider how replacing one element can merge two increasing runs. Identify that the replacement is most beneficial at the boundary between two runs, where the element breaks the increasing order.

4. Design algorithm for follow-up

Propose an O(n) algorithm: precompute lengths of increasing runs ending at each index and starting at each index. Then, for each potential replacement point, calculate the maximum length by combining runs if the replacement can bridge them.

5. Test and conclude

Walk through examples to validate the approach, including edge cases like all increasing, all decreasing, or single element. Summarize the solution and its complexity.

Key Points to Mention

  • Time and space complexity: O(n) time and O(n) space for precomputed arrays, or O(1) space with careful tracking.
  • Edge cases: empty array, single element, all elements equal, strictly decreasing array.
  • Sliding window technique for base case.
  • Precomputing increasing run lengths from left and right.
  • Condition for merging runs: the element before the replacement and the element after must allow a valid integer to be placed.
  • Handling the case where replacement is not needed (already increasing).

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