Interview Questions

270. You have been given a linked list of numbers.......

Microsoft Interview Questions and Answers


(Continued from previous question...)

270. You have been given a linked list of numbers.......

Question:

You have been given a linked list of numbers. The size is not known. You need to find out if the number stored in the list is a palindrome in the best possible optimized manner.


maybe an answer:


1. take slow and fast pointer, and find the mid-point //O(n)
2. reverse the list from mid-point till last //O(n)
3. check for palindrome // O(n)
4. again reverse the second half to get original list // O(n)

Total T.C = O(n)

(Continued on next question...)

Other Interview Questions