Question | Answer |
Remove Nth Node From End of List | public ListNode removeNthFromEnd(ListNode head, int n) { ListNode first = new ListNode(0); first.next = head; ListNode fast = first, slow = first; while(fast.next != null){ fast = fast.next; if(n-- < 1 ) slow = slow.next; } slow.next = slow.next.next; return first.next; } |
There are no comments, be the first and leave one below:
Want to create your own Flashcards for free with GoConqr? Learn more.