3254. Find the Power of K-Size Subarrays I
You are given an array of integers
nums
of lengthn
and a positive integerk
.The power of an array is defined as:
- Its maximum element if all of its elements are consecutive and sorted in ascending order.
- -1 otherwise.
You need to find the power of all subarrays of
nums
of sizek
.Return an integer array
results
of sizen - k + 1
, whereresults[i]
is the power ofnums[i..(i + k - 1)]
.