206-reverse-linked-list
DevGod needs to write a blog entry for this problem!
/**
* 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) {
let prev = null;
while(head != null){
next = head.next;
head.next = prev;
prev = head;
head = next;
}
return prev;
};