Maximum Subarray Sum with Length at Most K
Given an integer array nums and an integer K, return the maximum sum of a non-empty contiguous subarray whose length is at most K.
Input Format
n K
nums[0] nums[1] ... nums[n-1...
Example
Unlock to view complete problem details
and practice with sample input/output
Was this article helpful?
View Test Cases & Run Code requires membership
Standard Input
Execution Result:
