PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep

Quick Overview

Solve the longest increasing contiguous subarray problem in one pass. Includes Python code, edge cases, complexity, and a follow-up for returning the subarray range.

  • medium
  • Google
  • Coding & Algorithms
  • Data Scientist

Find Longest Increasing Continuous Subarray

Company: Google

Role: Data Scientist

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

Given an integer array `nums`, return the length of the longest contiguous strictly increasing subarray. "Contiguous" means the elements must appear next to each other in the original array. The subarray must be strictly increasing, so each next element must be greater than the previous element. Example: - Input: `[1, 3, 5, 4, 7]` - Output: `3` - Explanation: `[1, 3, 5]` is the longest contiguous strictly increasing segment. ### Constraints & Assumptions - Aim for `O(n)` time and `O(1)` extra space. - If the array is empty, return `0`. - If the array has one element, return `1`. - Equal adjacent values break a strictly increasing run. - You only need to return the length unless asked for the subarray itself. ### Clarifying Questions to Ask - Should an empty array return `0` or be treated as invalid input? - Do we need the actual subarray or only its length? - Are duplicate values allowed, and should equal values break the run? ### What a Strong Answer Covers - A one-pass scan that tracks the current increasing run length. - Resetting the current run when `nums[i] <= nums[i - 1]`. - Updating the best length at each step. - Correct handling of empty arrays, one-element arrays, duplicates, and decreasing arrays. - Time and space complexity. ### Follow-up Questions - How would you return the start and end indices of the longest run? - How does this differ from the longest increasing subsequence? - How would you solve the circular-array version? - What changes if non-decreasing subarrays are allowed?

Quick Answer: Solve the longest increasing contiguous subarray problem in one pass. Includes Python code, edge cases, complexity, and a follow-up for returning the subarray range.

Return the length of the longest contiguous strictly increasing subarray.

Constraints

  • Inputs are Python literals matching the function signature.
  • Return a deterministic exact-match value.

Examples

Input: ([1,3,5,4,7],)

Expected Output: 3

Explanation: Prompt example.

Input: ([],)

Expected Output: 0

Explanation: Empty array.

Input: ([2,2,2],)

Expected Output: 1

Explanation: Equal breaks run.

Input: ([1,2,3,4],)

Expected Output: 4

Explanation: Whole array.

Hints

  1. Pick a representation that makes the requested operation direct.
  2. Handle empty inputs and boundary cases first.
Last updated: Jun 27, 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
  • 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

  • Infection Spread on a Grid (Cellular Automaton) - Google (hard)
  • Boolean Expression Tree with Leaf Flips - Google (medium)
  • Streaming Points: Remove Any Pair Within a Distance - Google (medium)
  • Most Active Users in a Live Communication Stream - Google (medium)
  • Solve Rooms and Top-K Streams - Google (medium)