1. /**
    2. * Definition for singly-linked list.
    3. * function ListNode(val) {
    4. * this.val = val;
    5. * this.next = null;
    6. * }
    7. */
    8. /**
    9. * @param {ListNode} head
    10. * @return {ListNode}
    11. */
    12. var reverseList = function(head) {
    13. let cur = null,
    14. tail = null
    15. while(head !== null) {
    16. tail = head
    17. head = head.next
    18. tail.next = cur
    19. cur = tail
    20. }
    21. return tail
    22. };