Question: Moderate - 9 8 0 8 0 . Average time to solve is 3 0 m ( c ) Contributed by Amit 3 8 6
Moderate Average time to solve is
c
Contributed by Amit
upvates
Asked in companies
Problem statement
Send feedback
Ninja and his friend are playing a game of subarrays. They have an array 'NUMS' of length N: Ninja's friend gives him an arbitrary integer and asks him to find the length of the longest subarray in which the sum of elements is equal to :
Ninjas asks for your help to win this game Find the length of the longest subarray in which the sum of elements is equal to
If there is no subarray whosesum is : then you should return
Example:
input:
Output:
There are two subarrays with um and Hence the fength of the longest subarray with sum is
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
