Update 0019、0066

This commit is contained in:
YDZ
2021-04-16 00:12:51 +08:00
parent 7f0a3b514f
commit 86fac4e139
3 changed files with 84 additions and 24 deletions

View File

@ -2,16 +2,44 @@
## 题目
Given a linked list, remove the n-th node from the end of list and return its head.
Given the `head` of a linked list, remove the `nth` node from the end of the list and return its head.
Example:
**Follow up:** Could you do this in one pass?
**Example 1:**
![](https://assets.leetcode.com/uploads/2020/10/03/remove_ex1.jpg)
```
Given linked list: 1->2->3->4->5, and n = 2.
Input: head = [1,2,3,4,5], n = 2
Output: [1,2,3,5]
After removing the second node from the end, the linked list becomes 1->2->3->5.
```
**Example 2:**
```
Input: head = [1], n = 1
Output: []
```
**Example 3:**
```
Input: head = [1,2], n = 1
Output: [1]
```
**Constraints:**
- The number of nodes in the list is `sz`.
- `1 <= sz <= 30`
- `0 <= Node.val <= 100`
- `1 <= n <= sz`
## 题目大意
删除链表中倒数第 n 个结点。