Tap here to switch tabs
Problem
Submissions

Problem: Find the Power of K-Size Subarrays II

Find the Power of K-Size Subarrays II asks you to evaluate every subarray of size k, returning its largest value when it forms an ascending consecutive sequence, or negative one otherwise.

Statement

You are given an array of integers nums of length n, and a positive integer k.

The power of an array is defined as:

  • Its maximum element if its elements are consecutive and sorted in ascending order.

  • −1-1 otherwise.

Return an array of integers representing the power of every subarray of nums of size k, ordered from the first subarray to the last.

Constraints:

  • 1≤1 \leq n ==== nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤106\leq 10^6

  • 1≤1 \leq k ≤\leq n

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Find the Power of K-Size Subarrays II

Find the Power of K-Size Subarrays II asks you to evaluate every subarray of size k, returning its largest value when it forms an ascending consecutive sequence, or negative one otherwise.

Statement

You are given an array of integers nums of length n, and a positive integer k.

The power of an array is defined as:

  • Its maximum element if its elements are consecutive and sorted in ascending order.

  • −1-1 otherwise.

Return an array of integers representing the power of every subarray of nums of size k, ordered from the first subarray to the last.

Constraints:

  • 1≤1 \leq n ==== nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤106\leq 10^6

  • 1≤1 \leq k ≤\leq n