Print all subarrays of a given array.
Difficulty: Hard
Phase: 6 · Mixed Logical Challenges
XP Reward: 30 XP
Topics: Mixed Logical Challenges, Hard
Supported Languages: Python, JavaScript, C, C++, Java
Problem Description
Given N positive integers on line 2 and target S on line 3, find the minimal length of a contiguous subarray of which the sum >= S. If none exists, print 0. Input Format: Read input from standard input (stdin). Output Format: Print the result to standard output (stdout).
Constraints
- -10^9 <= N <= 10^9
Examples
Example 1
Input: 6 2 3 1 2 4 3 7
Output: 2
Explanation: Sample execution for input 6 2 3 1 2 4 3 7