{"size": 697, "ext": "js", "max_stars_repo_path": "day:84/deleteNode.js", "max_stars_repo_name": "hawaijar/FireLeetcode", "max_stars_repo_stars_event_min_datetime": "2020-10-21T12:28:23.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-21T12:28:23.000Z", "max_issues_repo_path": "day:84/deleteNode.js", "max_issues_repo_name": "hawaijar/FireLeetcode", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "day:84/deleteNode.js", "max_forks_repo_name": "hawaijar/FireLeetcode", "max_forks_repo_forks_event_min_datetime": "2020-10-21T12:28:24.000Z", "max_forks_repo_forks_event_max_datetime": "2020-10-21T12:28:24.000Z"}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": 1, "avg_line_length": 24.8928571429, "max_line_length": 91, "alphanum_fraction": 0.5982783357}
/**
 * Definition for singly-linked list.
 * function ListNode(val) {
 *     this.val = val;
 *     this.next = null;
 * }
 */
/**
 * @param {ListNode} node
 * @return {void} Do not return anything, modify node in-place instead.
 */
var deleteNode = function(node) {
    // the idea is to keep shifting to the right all the nodes after the node to be deleted
    let current = node;
    let next = current.next;
    let temp = current;
    
    while(next !== null) {
        current.val = next.val;
        temp = current;
        current = next;
        next = next.next;
    }
    // since we're always shifting to the right, the last node must always be deleted.
    temp.next = null;
    
};
