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

Reverse a Singly Linked List

Adobe logoAdobe● EasyFULLTIMEINTERNPHONE SCREEN
QuestionFunctionExamplesConstraints

Problem statement

Source note: This was the coding part of a C++-heavy technical interview in the candidate's first Adobe attempt: reverse a linked list. The rest of the round was C++ output questions. The report names the task and nothing more.

It gives no limits or examples. Here the list has 0 to 500 nodes with values from -1000 to 1000, and the examples are our own.

The judged task matches the report at about 95%.

You are given the head of a singly linked list. Reverse the list so that its last node becomes the first and every link points the other way, and return the new head.

If the list is empty, return an empty list.

Function

reverseLinkedList(head: ListNode) → ListNode

Examples

Example 1

head = [3,8,1]return = [1,8,3]

The links are turned around: the old tail 1 becomes the new head, and the old head 3 becomes the new tail.

Example 2

head = [-7,0,7,0]return = [0,7,0,-7]

Read from the end, the values are 0, 7, 0, -7. Equal values (the two zeros) are still separate nodes, and each one is kept.

Example 3

head = [6,-2]return = [-2,6]

With two nodes, the second node now points to the first, and the first points to nothing.

Constraints

  • The list has between 0 and 500 nodes.
  • -1000 <= node.val <= 1000

More Adobe problems

  • Evaluate a Parenthesized Integer ExpressionPHONE SCREEN · Seen Oct 2026
  • All Elements of Two BSTs in OrderPHONE SCREEN · Seen Aug 2026
  • Rotate an Array In PlaceOA · PHONE SCREEN · Seen Aug 2026
All Adobe interview questionsSee Adobe hiring insights
Saved
public ListNode reverseLinkedList(ListNode head) {
    // Write your code here.
}
Checking account…