#K1506. Subarray Sum Finder
Subarray Sum Finder
Subarray Sum Finder
Given an array of non-negative integers and a target sum \(T\), determine whether there exists a contiguous subarray whose elements sum exactly to \(T\). This problem requires you to implement a function that reads the input from standard input (stdin) and writes the result to standard output (stdout).
Note: The input array can be empty. The contiguous subarray should contain one or more elements. The algorithm should run in linear time \(O(n)\) using the sliding window technique since all integers are non-negative.
Example:
Input: 5 12 1 2 3 7 5</p>Output: found
inputFormat
The first line of input contains two integers \(n\) and \(T\), where \(n\) is the number of elements in the array and \(T\) is the target sum. The second line contains \(n\) non-negative integers separated by spaces.
If \(n = 0\), the second line will be empty.
outputFormat
Output a single line containing found
if there exists a contiguous subarray with sum exactly \(T\), otherwise output not found
.
5 12
1 2 3 7 5
found