i think one more case should be added If(arr[i]==k && len==0){len=1;}
and also when im getting mp[pre-k] int the map then also we should do m[pre]=i;
i think one more case should be added If(arr[i]==k && len==0){len=1;}
and also when im getting mp[pre-k] int the map then also we should do m[pre]=i;
@deepakjumani09
the first case is handled because we mark mp[0] also.
if mp[pre] already exists then we won’t do mp[pre] because we want longest subarray.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.