Skip to content

6 2 月, 2021

LeetCode: 19-Remove Nth Node From End of List 解題紀錄

Last Updated on 2021-02-07 by Clay


題目

Given the head of a linked list, remove the nth node from the end of the list and return its head.

Follow up: Could you do this in one pass?

Example:

Input: head = [1,2,3,4,5], n = 2
Output: [1,2,3,5]

本題給定一個鏈結串列(Linked List),而我們要做的,便是將倒數第 n 個元素刪除,並回傳刪除後的 Linked List。

Read More »LeetCode: 19-Remove Nth Node From End of List 解題紀錄
Exit mobile version