This person's solution is an example of what I am talking about: https://discuss.leetcode.com/topic/11463/java-o-n-solution-very-easy-to-understand/2.
I do not understand why the code only works if you write:
ListNode head = new ListNode(0); ListNode current = head;
And doesn't work if you write:
ListNode head = new ListNode(0); ListNode current = new ListNode(0);
Like why do you have to set current to head? I am stuck.
In addition to that, why is head.next returned? It seems like the code does not modify the head at all so I have no idea why returning head.next works because to me it seems like head.next would be empty. Please someone help me!