Problem
Given the head of a singly linked list, reverse the list, and return the new head node. The linked list is defined as follows:
class ListNode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
Constraints
- 0 <= number of nodes <= 5000
- -5000 <= Node.val <= 5000
Function Signature
def reverse_list(head: Optional[ListNode]) -> Optional[ListNode]:
Practicing as: Software Engineer interview at ConnectiCareHi, I'll play your ConnectiCare interviewer for the Software Engineer role. Candidates describe these interviews as mostly positive and moderately difficult, so expect me to be friendly and conversational. Take your time with the question above and answer like we're in the room.
You are practicing as a guest. Sign up free to run your code against the sample data. Your draft stays right here.



