As reported: Cisco, networking/C-focused role, round 1 DSA part (2026): reverse a singly linked list.
Given the head of a singly linked list, reverse it and return the new head.
This is LeetCode 206 — Reverse Linked List.
Example 1
head = [1,2,3,4,5] -> [5,4,3,2,1]
Example 2
head = [1,2] -> [2,1]
Constraints: 0 ≤ length ≤ 5000; -5000 ≤ Node.val ≤ 5000.
Code runner format: one line, the list as a JSON array. Implement reverseList(head); the harness prints the reversed list.