FastPrepPalindrome Linked List with Restoration
Problems/Palindrome Linked List with Restoration

Palindrome Linked List with Restoration

Microsoft logoMicrosoft● MediumFULLTIMEINTERNONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Microsoft onsite interview. The report does not say what shape the restored list should be returned in so that it can be checked. Our version is about 97% the same as the reported question.

Given the head of a non-empty singly linked list, determine whether its values form a palindrome while using constant auxiliary space for the comparison.

Reverse the second half in place, compare the two halves, and restore the list before returning. Return an integer array whose first value is 1 when the list is a palindrome and 0 otherwise; the remaining values must be the restored list from head to tail.

Function

checkAndRestorePalindrome(head: ListNode) → int[]

Examples

Example 1

head = [1,2,2,1]return = [1,1,2,2,1]
head
1221

The values are palindromic, and the returned suffix proves that the original order was restored.

Example 2

head = [1,2,3]return = [0,1,2,3]
head
123

The end values differ, but the list still appears in its original order after the check.

Constraints

  • The list contains at least one node.
  • Every node value is a signed integer.
  • The list is acyclic.

More Microsoft Onsite Interview questions

  • Bad Request AlertsONSITE INTERVIEW · Seen Nov 2026
  • Longest Substring Without Repeating CharactersONSITE INTERVIEW · Seen Nov 2026
  • Valid ParenthesesONSITE INTERVIEW · Seen Nov 2026
  • Count a User's Actions in an Event LogONSITE INTERVIEW · Seen Nov 2026
  • Smallest Batch Size Within a Step LimitONSITE INTERVIEW · Seen Nov 2026
  • Count Subarrays with Equal Even and Odd CountsONSITE INTERVIEW · Seen Nov 2026
  • Minimum Time to Rot All OrangesONSITE INTERVIEW · Seen Nov 2026
  • Coin ChangeONSITE INTERVIEW · Seen Oct 2026
  • Daily USD Totals with Effective-Dated Exchange RatesONSITE INTERVIEW · Seen Oct 2026
  • Number Words to Digits in Any LanguageONSITE INTERVIEW · Seen Oct 2026

Similar questions at other companies

  • Remove Nth Node From End of ListDruva · ONSITE INTERVIEW
  • Find the Entry of a Linked List CycleQualys · ONSITE INTERVIEWQualys interview questions
  • Detect a Linked-List CyclePaytm · ONSITE INTERVIEWPaytm interview questions
  • Detect a Linked-List CycleCapgemini · ONSITE INTERVIEWCapgemini interview questions
  • Rearrange a Linked List from Alternating EndsConcentric AI · ONSITE INTERVIEWConcentric AI interview questions
  • Linked List Cycle Entry NodeGoogle · ONSITE INTERVIEWGoogle interview questions
  • Detect and Break a Linked-List CycleAmazon · ONSITE INTERVIEW
  • Odd-Even Linked ListBloomberg LP · ONSITE INTERVIEWBloomberg LP interview questions
  • Find the Entry of a Linked List CyclePeopleStrong · ONSITE INTERVIEWPeopleStrong interview questions
  • Remove a Cycle from a Singly Linked ListExpedia · ONSITE INTERVIEWExpedia interview questions

Interview reports that mention this question

  • Microsoft SWE Intern, Early 2026: 54 Experiences (Part 2 of 6)
  • Microsoft SWE Intern Interviews: 244 Experiences (Part 1 of 6)

Microsoft interview experiences

  • Microsoft OA Questions, October 2026: 4 Experiences
  • Microsoft Experienced SWE Phone Screen: 1 Experience
  • Microsoft Explore and Student SWE: 12 Experiences (Part 6 of 6)
  • Microsoft SWE Intern, Early 2025: 41 Experiences (Part 5 of 6)
All Microsoft interview questionsSee Microsoft hiring insights
Saved
/**
 * Definition for singly-linked list.
 * public class ListNode {
 *     int val;
 *     ListNode next;
 *     ListNode() {}
 *     ListNode(int val) { this.val = val; }
 *     ListNode(int val, ListNode next) { this.val = val; this.next = next; }
 * }
 */
class Solution {
    public int[] checkAndRestorePalindrome(ListNode head) {
        // TODO: check the palindrome and restore the linked list.
    }
}
Checking account…