Tap here to switch tabs
Problem
Submissions

Problem: Find the Power of K-Size Subarrays II

med
30 min
Try to solve the Find the Power of K-Size Subarrays II problem.

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

med
30 min
Try to solve the Find the Power of K-Size Subarrays II problem.

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