/**
* Definition for singly-linked list.
* function ListNode(val) {
* this.val = val;
* this.next = null;
* }
*/
/**
* @param {ListNode} head
* @return {ListNode}
*/
var reverseList = function(head) {
let cur = null,
tail = null
while(head !== null) {
tail = head
head = head.next
tail.next = cur
cur = tail
}
return tail
};