educative.io

Educative

Should not the OR condition (head === null || halfReversed === null) be AND contion (head === null && halfReversed === null)

head === null || halfReversed === null
The above conditions has comment if both halves match
But the code says otherwise.

I think it’s a typo and should be corrected to head === null && halfReversed === null

Any thoughts?

Thanks

1 Like

hi Gaurav
I don’t think its a typo
consider this example:
1->2->2->1
after comparing head with head_second_half, head will move to 2nd 2 whereas head_second_half will move to null

2 Likes