Easy · Linked Lists
Reverse linked list (Linked lists)
Given the head of a singly linked list, reverse the list in place and return its new head (the old tail).
Examples
Example 1
{
"values": [1, 2, 3, 4, 5]
}Output: 5 → 4 → 3 → 2 → 1
Example 2
{
"values": [7, 8, 9]
}Output: 9 → 8 → 7
Rebuild it in the studio
Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.