LeetCode – Remove Nth Node From End of List (Java)
Given a linked list, remove the nth node from the end of list and return its head. For example, given linked list 1->2->3->4->5 and n = 2, the result is 1->2->3->5. Java Solution 1 – Naive Two Passes Calculate the length first, and then remove the nth from the beginning. public ListNode removeNthFromEnd(ListNode head, int … Read more