You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public ListNode removeNthFromEnd(ListNode head, int n) {
if(head==null) return head;
ListNode block=head;
for(int i = 0; i<n; i++){
block=block.next; //I imagine a person walking into a wall with a long block of wood protruding from their chest. When the block hits the wall, you've found the one to delete!
}
ListNode start=new ListNode(-1); start.next=head; //connect start to head