public class Solution {
public ListNode ReverseList(ListNode head) {
if(head == null || head.next == null) {
return head;
}
ListNode newHead = null;
ListNode current = head.next;
while(current != null) {
head.next = newHead;
newHead = head;
head = current;
current = current.next;
}
head.next = newHead;
newHead = head;
return newHead;
}
}