#C2123. Find Subarray with Given Sum
Find Subarray with Given Sum
Find Subarray with Given Sum
You are given an integer array and a target sum (T). Your task is to determine whether there exists a contiguous subarray whose sum is exactly (T). If such a subarray exists, output "Yes" followed by the starting and ending indices (1-indexed) of the first subarray found; otherwise, output "No".
The problem requires reading multiple test cases from standard input. For each test case, the first line contains two integers: (n) (the number of elements in the array) and (T) (the target sum). The following line contains (n) integers representing the array. Your solution must output the answer for each test case on a new line.
inputFormat
The first line of input contains an integer (T), the number of test cases. For each test case, the first line contains two integers (n) and (T) separated by a space, where (n) is the number of elements in the array and (T) is the target sum. The second line contains (n) space-separated integers representing the array.
outputFormat
For each test case, output a single line. If there exists a contiguous subarray with sum equal to (T), print "Yes" followed by two integers denoting the 1-indexed starting and ending positions of the subarray. Otherwise, print "No".## sample
3
5 12
1 2 3 7 5
4 10
1 2 3 4
3 5
1 -1 2
Yes 2 4
Yes 1 4
No
</p>