/**
* Definition for singly-linked list.
* public class ListNode {
* public int val;
* public ListNode next;
* public ListNode(int x) { val = x; }
* }
*/
public class Solution {
public ListNode ReverseList(ListNode head) {
ListNode h = null;
while(head != null){
var n = new ListNode(head.val);
n.next = h;
h = n;
head = head.next;
}
return h;
}
}