FastPrepReverse a Singly Linked List
Problems/Reverse a Singly Linked List

Reverse a Singly Linked List

Microsoft logoMicrosoft● EasyNEW GRADINTERNONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A Microsoft New Grad interview report asked candidates to reverse a linked list and handle null input. The report left out the function signature, the size limits and the range of values, so we state the usual ones here. Our version is about 95% the same as the reported question.

Given the head head of a singly linked list, reverse every next pointer and return the new head.

The returned list must contain exactly the original nodes and values in reverse order. Return null when head is null.

Function

reverseList(head: ListNode) → ListNode

Examples

Example 1

head = [1,2,3,4,5]return = [5,4,3,2,1]
head
12345
→
return
54321
Moved or new

Every link is reversed, making 5 the new head and 1 the new tail.

Example 2

head = []return = []
head
empty
return
empty

A null head remains null.

Example 3

head = [7]return = [7]
head
7
→
return
7

A one-node list is already reversed.

Constraints

  • 0 <= number of nodes <= 10^5
  • -10^9 <= node.val <= 10^9
  • The input list is finite and 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

  • Reverse a Singly Linked ListBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Merge Two Sorted ListsLinkedIn · PHONE SCREENLinkedIn interview questions
  • Merge Two Sorted ListsThe Walt Disney Company · OAThe Walt Disney Company interview questions
  • Reverse Linked ListAutodesk · ONSITE INTERVIEWAutodesk interview questions
  • Detect a Loop in a Linked ListEPAM · ONSITE INTERVIEWEPAM interview questions
  • Merge Two Sorted Linked ListsZS · ONSITE INTERVIEWZS interview questions
  • Middle Node Of A Linked ListNVIDIA · ONSITE INTERVIEWNVIDIA interview questions
  • Build and Check a Palindrome Linked ListOmnissa · ONSITE INTERVIEWOmnissa interview questions
  • Reverse a Singly Linked ListGEP · ONSITE INTERVIEW
  • Merge Two Sorted Linked ListsApple · ONSITE INTERVIEWApple interview questions

Interview reports that mention this question

  • Microsoft SWE Intern, Early 2025: 41 Experiences (Part 5 of 6)
  • Microsoft SWE Intern, Mid 2025: 42 Experiences (Part 4 of 6)
  • 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
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 ListNode reverseList(ListNode head) {
      // write your code here
    }
}
Checking account…