Shortest Subarray With Sum At Least K

JavaScript Hard 3 views
Back to Questions

Problem Description

Given array (can have negatives) and value K, find the length of shortest subarray with sum >= K. If not found, print -1.

Input Format

Line1: n K. Line2: n integers.

Output Format

One integer length.

Sample Test Case

Input:
6 7 2 -1 2 3 -2 4
Output:
2

Constraints

1

Solutions (0)

No solutions submitted yet. Be the first!

Discussion (0)

No comments yet. Start the discussion!

Prev Next