Palindrome Linked List
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
Given the head of a singly linked list of digits, decide whether the sequence of values reads identically from front to back and from back to front.
Return true if it does and false otherwise. A single-node list is always a palindrome.
A linear-time solution that copies the values into an array is fine, but try for O(n) time with O(1) extra space by reversing part of the list in place.
Examples
Constraints
- 1 <= number of nodes <= 10^5
- 0 <= Node.val <= 9
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.