public ListNode reverseList(ListNode head) {
if(head == null) {
return null;
}
ListNode first = head;
head = head.next;
first.next = null;
while (head != null) {
ListNode current = head;
head = head.next;
current.next = first;
first = current;
}
return first;
}