Easy problem, without memory leaks


  • 1

    Easy problem to solve and for those who are worry about memory leaks, Java garbage collector should clean up the unreferenced node.

    public class Solution {
        public void deleteNode(ListNode node) {
            if(node != null){
                node.val = node.next.val;
                node.next = node.next.next ;
            }
        }
    }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.