Skip to main content
Back to problems
Leetcode
Medium
Arrays
Greedy
Simulation
Adjacent Increasing Subarrays Detection I

Determine whether an array contains two adjacent strictly increasing subarrays of a given length.

Acceptance 0%
Problem Statement

Problem

Given an integer array nums and an integer k, determine whether there exist two adjacent subarrays of length k such that:

  • the first subarray is strictly increasing,
  • the second subarray is also strictly increasing,
  • the second subarray starts immediately after the first one ends.

In other words, you are looking for a contiguous segment of length 2k where both halves of length k are strictly increasing.

Return true if such a pair exists, otherwise return false.

Notes

  • A subarray is a contiguous part of the array.
  • A strictly increasing subarray means every element is greater than the previous one.

Input Format

  • An integer array nums.
  • An integer k.

Output Format

  • Return a boolean value indicating whether the required adjacent increasing subarrays exist.

Input Format

  • nums: integer array
  • k: positive integer

Output Format

  • Return true if there are two adjacent strictly increasing subarrays of length k; otherwise return false.

Constraints

  • 1 <= k <= nums.length / 2
  • nums contains integers
  • The array length is at least 2k
Examples
Sample cases returned by the problem API.

Example 1

Input

nums = [1,2,3,1,2,3], k = 3

Output

true

Explanation

The subarray [1,2,3] is strictly increasing, and the adjacent subarray [1,2,3] is also strictly increasing.

Example 2

Input

nums = [1,2,1,2,3], k = 2

Output

true

Explanation

The subarrays [1,2] and [1,2] at positions [0..1] and [2..3] are adjacent and both strictly increasing.

Show 1 more example

Example 3

Input

nums = [5,4,3,2,1], k = 2

Output

false

Explanation

There is no pair of adjacent subarrays of length 2 that are both strictly increasing.

Premium problem context

Unlock deeper context for this problem

Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.

Guided hints
Editorial and discussion links
Concept map and variants
Sign in to unlock
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.