VALUEBOUND Off-Campus OA (2023) | Problem Find the Power of K-Size Subarrays

Question · Posted Jun 2026

Problem Statement Given an integer array nums and an integer k, determine the power of every subarray of size k. A subarray is considered powerful if: nums[i+1] = nums[i] + 1 for every adjacent pair inside the subarray. Power of a valid subarray: Maximum element of that subarray Otherwise: -1 Return an array containing powers of all subarrays of size k. Example Input: nums = [1,2,3,4,3,2,5] k = 3 Output: [3,4,-1,-1,-1] Test Cases Test Case 1 Input: nums = [1,2,3,4,3,2,5] ...

The full answer & interview discussion are available to premium members.

Log in Create a free account