Practice Find the Power of K-Size Subarrays II
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
For each contiguous subarray of nums with length k, return its maximum element if its values increase by exactly 1 at every step, and -1 otherwise. Return these powers in increasing order of the subarray’s starting index.
Source: Find the Power of K-Size Subarrays II on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
nums = [1,2,3,4,3,2,5], k = 3
Output
[3,4,-1,-1,-1]
# Example 2
Input
nums = [2,2,2,2,2], k = 4
Output
[-1,-1]
# Example 3
Input
nums = [3,2,3,2,3,2], k = 2
Output
[-1,3,-1,3,-1]
Constraints
1 <= n == nums.length <= 10^5
1 <= nums[i] <= 10^6
1 <= k <= n
Related LeetCode Problems
Practice more problems similar to Find the Power of K-Size Subarrays II.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.