Given the head of a singly linked list, reverse the list in place and return the new head.
head = [1,2,3,4,5][5,4,3,2,1]head = [][]Try it now — no sign-up needed. Write your solution in Python or JavaScript, run it against test cases, and submit for a verdict, right in your browser.
Open the editor →A chain of nodes, each pointing to the next. No random access like an array, but insertion and deletion at a known position is O(1), and many classic problems come down to careful pointer rewiring.
Read the full Linked List guide →
Original problem on LeetCode ↗