/*
public class ListNode {
int val;
ListNode next = null;
ListNode(int val) {
this.val = val;
}
}*/
public class Solution {
public ListNode ReverseList(ListNode head) {
if(head == null) {
return null;
}
ListNode h = head;
head = head.next;
h.next = null;
ListNode cur = head;
while(cur != null) {
head = head.next;
cur.next = h;
h = cur;
cur = head;
}
return h;
}
}