最短の、空でない、連続した部分配列の長さ戻り A
少なくとも和とを K
。
合計とは、空でない部分配列が存在しない場合は、少なくとも K
、返します -1
。
例1:
Input: A = [1], K = 1
Output: 1
例2:
Input: A = [1,2], K = 4
Output: -1
例3:
Input: A = [2,-1,2], K = 3
Output: 3
注意:
1 <= A.length <= 50000
-10 ^ 5 <= A[i] <= 10 ^ 5
1 <= K <= 10 ^ 9
Githubの同期住所:
https://github.com/grandyang/leetcode/issues/862
参考文献:
https://leetcode.com/problems/shortest-subarray-with-sum-at-least-k/