Skip to content

Latest commit

 

History

History
121 lines (48 loc) · 1.59 KB

File metadata and controls

121 lines (48 loc) · 1.59 KB

中文文档

Description

Return the length of the shortest, non-empty, contiguous subarray of A with sum at least K.

If there is no non-empty subarray with sum at least K, return -1.

 

Example 1:

Input: A = [1], K = 1

Output: 1

Example 2:

Input: A = [1,2], K = 4

Output: -1

Example 3:

Input: A = [2,-1,2], K = 3

Output: 3

 

Note:

    <li><code>1 &lt;= A.length &lt;= 50000</code></li>
    
    <li><code>-10 ^ 5&nbsp;&lt;= A[i] &lt;= 10 ^ 5</code></li>
    
    <li><code>1 &lt;= K &lt;= 10 ^ 9</code></li>
    

Solutions

Python3

Java

...