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

Reverse a Singly Linked List

Google logoGoogle● EasyINTERNONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report gives the task of reversing the whole list, the behavior for empty and single-node lists, duplicate values, the iterative pointer steps and complexity, and follow-ups for recursion and sublists. It leaves out only the input limits and the function signature. Our version is about 98% the same as the reported question.

You are given the head head of a finite singly linked list of contacts. Reverse every next pointer in place and return the new head.

The returned list must contain exactly the original nodes and values in reverse order. Node values may repeat. If head is null, return null; if the list contains one node, return that same node.

Interview extensions

  • Explain how to reverse the complete list recursively.
  • Explain how to reverse only a contiguous segment from the m-th node through the n-th node.

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 pointer is reversed, so the original tail becomes the new head.

Example 2

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

An empty list has no nodes to reverse, so the result is null.

Example 3

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

A one-node list is already reversed, so the same node is returned.

Example 4

head = [1,1,2]return = [2,1,1]
head
112
→
return
211
Moved or new

Repeated values are preserved because the nodes, rather than a set of values, are reversed.

Constraints

  • 0 <= number of nodes <= 100000
  • -10^9 <= node.val <= 10^9
  • The input list is finite and acyclic.
  • Each node has only a next pointer; there is no prev pointer.

More Google Onsite Interview questions

  • Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Distinct Subset SumsONSITE INTERVIEW · Seen Nov 2026
  • Playlist With No Same Artist in a RowONSITE INTERVIEW · Seen Nov 2026
  • Delete Nodes and Return Forest RootsONSITE INTERVIEW · Seen Nov 2026
  • Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • First and Last Target Position in a Mountain ArrayONSITE INTERVIEW · Seen Nov 2026
  • Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • 0/1 Knapsack with Weight and Volume LimitsONSITE INTERVIEW · Seen Nov 2026
  • Batched Subsequence Word MatchesONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Reverse Linked ListAutodesk · ONSITE INTERVIEWAutodesk interview questions
  • Detect a Loop in a Linked ListEPAM · ONSITE INTERVIEWEPAM interview questions
  • Delete a Doubly Linked List Node at a PositionQualys · ONSITE INTERVIEWQualys interview questions
  • Insert After a Linked-List NodeAMD · ONSITE INTERVIEWAMD interview questions
  • Process Singly Linked List OperationsSEDEMAC · ONSITE INTERVIEW
  • 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

Google interview experiences

  • Google interviews · November 2026
  • Google Software Engineer Onsite Questions: 10 Experiences
  • Google OA: What It Tests (2026)
  • Google L4 SWE Phone Screen: 1 Experience
  • Google ML Engineering Manager Onsite: 1 Experience
  • Google Experienced SWE First Round and Onsite: 1 Experience
All Google interview questionsSee Google 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…