# [3254\. Find the Power of K-Size Subarrays I](https://leetcode.com/problems/find-the-power-of-k-size-subarrays-i/) :::spoiler Hint ```cpp= ``` ::: :::spoiler Solution ```cpp= class Solution { public: vector<int> resultsArray(vector<int>& nums, int k) { if (k == 1) return nums; vector<int> res; int n = nums.size(); int i = 1, consecutiveSize = 1; while (i < n) { if (nums[i - 1] + 1 == nums[i]) { consecutiveSize++; } else { consecutiveSize = 1; } if (i + 1 >= k) { if (consecutiveSize >= k) { res.push_back(nums[i]); } else { res.push_back(-1); } } i++; } return res; } }; ``` - T: $O(n)$ - S: $O(n)$ :::
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up