Smallest Subarray Sum at Least S

Python Hard 2 views
Back to Questions

Problem Description

Read n integers (can be positive, zero) and target S. Compute the minimum length of a contiguous subarray with sum >= S. If not found, output 0.

Input Format

First line n S. Second line n integers (all non-negative).

Output Format

One integer minLen or 0.

Sample Test Case

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

Constraints

1

Solutions (0)

No solutions submitted yet. Be the first!

Discussion (0)

No comments yet. Start the discussion!

Prev Next