Longest subarray with sum k

https://ide.codingblocks.com/s/442234,
check this code ,this is showing wrong output.

hello @CODER_JATIN

check now->


u need to push pre in map only if it is not present.

https://ide.codingblocks.com/s/442249 ,bhaiya ab bhi sahi ni aa ri output

sahi to aa raha hai bro,
answer 7 hi to hoga

bhaiya k ki value 15 di hai , to length of longest subarray with sum 15 to 3 ni hoga?

nahi, jo red se highlight kiya hai subarray uska sum bhi 15 hai aur uski length 7 hai ,isiliye answer 7 hai

Arey hanji bhaiya aa gya samjh aa gya , dimag kahi or chal rha tha mera :grinning::grinning::grinning:

:+1: :+1:
… . . . . . . . . . . . . . . . . .

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.