Longest Sub Array With Sum K

easy
1.Given an array containing N integers and an integer K. 2.Your task is to find the length of the longest Sub-Array with sum of the elements equal to the given value K. 3.You have to complete the function print() which should print the length of the longest Sub-Array with sum of the elements equal to the given value K.

Input Format

1.First Line contains two space separated elements 'N' and 'K' denoting the size of the array and target sum respectively. 2.Second line contains the 'N' Space separated elements of the array.

Output Format

Print the required lenght of the longest Sub-Array in new line. If no such sub array can be formed print 0.

Constraints

1<=N,K<=10^5
 -10^5<=A[i]<=10^5

Notice

Try First, Check Solution later

1. You should first read the question and watch the question video.
2. Think of a solution approach, then try and submit the question on editor tab.
3. We strongly advise you to watch the solution video for prescribed approach.

Example

Input
6 15
10 5 2 7 1 9
Output
4
Previous
Longest Palindrome
Next
Longest Substring With Equal Number Of 0s And 1s

Related Questions