Back to course home
0% completed
Vote For New Content
No need to check head != null (refer to the attached image)because in 1st case (...
Santosh Vaza
Oct 9, 2022
No need to check head != null (refer to the attached image)
because in 1st case (1st underline in image) headSecondHalf will exhaust sooner than the head itself, since headSecondHalf is reversed, there is no way where the head will exhaust before headSecondHalf.
In 2nd case, we can confirm its palindrome when headSecondHalf is null so there is no need to check head==null as well.

2
0
Comments
Comments
On this page