same approach as 108 Leetcode, but it's great idea :) Thanks
@itsurabhi506
3 ай бұрын
best👌
@_eazyalgo
3 ай бұрын
Thanks :)
@yanchengpan543
3 жыл бұрын
hey thank you for the video. can you explain again why mid.next needs to be null? wont the mid be re-declared at every recursion?
@RiteshYadav-rc1np
3 жыл бұрын
yaa same doubt and i dont see any use of mid in the program it canbe also done by slow pointer but without mid the program is not working
@_eazyalgo
3 жыл бұрын
mid.next is set to null so it doesn't repeat its value, it is first declared null then slow pointer is assigned to mid. (Sorry for late reply I was busy in my exams).
@Mandeepsingh-jo5cf
3 жыл бұрын
let us take a example for that: in the first recursion: slow is at 0, and we make slow.next to null. now, because of slow.next is null, the next slow we get is -3. I think it can also be done by slow.next=NULL at the position of mid.next=NULL; hope this helps.
@_eazyalgo
3 жыл бұрын
@@Mandeepsingh-jo5cf Thanks, setting slow.next to null will do the job
Пікірлер: 11