/**
* Definition for singly-linked list.
* function ListNode(val, next) {
* this.val = (val===undefined ? 0 : val)
* this.next = (next===undefined ? null : next)
* }
*/
/**
* @param {ListNode} head
* @return {ListNode}
*/
var reverseList = function(head) {
if(head==null) return head;
let stack=[];
let point=head;
while(point!=null){
stack.push(point);
point=point.next;
}
head=point=stack.pop();
while(stack.length>0){
point.next=stack.pop();
point=point.next;
}
point.next=null;
return head;
};