Update 链表相关.md

master
Omooo 4 years ago
parent d426bcfa6c
commit 4b4bc029a2
  1. 30
      blogs/Algorithm/剑指 Offer/链表相关.md

@ -2,6 +2,15 @@
链表相关
---
#### 目录
1. [06. 从头到尾打印链表](https://leetcode-cn.com/problems/cong-wei-dao-tou-da-yin-lian-biao-lcof/)
2. [18. 删除链表的节点](https://leetcode-cn.com/problems/shan-chu-lian-biao-de-jie-dian-lcof/)
3. [22. 链表中倒数第 k 个节点](https://leetcode-cn.com/problems/lian-biao-zhong-dao-shu-di-kge-jie-dian-lcof/)
4. [24. 反转链表](https://leetcode-cn.com/problems/fan-zhuan-lian-biao-lcof/)
5. [25. 合并两个排序的链表](https://leetcode-cn.com/problems/he-bing-liang-ge-pai-xu-de-lian-biao-lcof/)
6. [35. 复杂链表的复制](https://leetcode-cn.com/problems/fu-za-lian-biao-de-fu-zhi-lcof/)
[06. 从头到尾打印链表](https://leetcode-cn.com/problems/cong-wei-dao-tou-da-yin-lian-biao-lcof/)
```java
@ -43,6 +52,26 @@ class Solution {
}
```
[18. 删除链表的节点](https://leetcode-cn.com/problems/shan-chu-lian-biao-de-jie-dian-lcof/)
```java
class Solution {
public ListNode deleteNode(ListNode head, int val) {
ListNode h0 = new ListNode(0);
ListNode h1 = h0;
h0.next = head;
while (h0.next != null) {
if (h0.next.val == val) {
h0.next = h0.next.next;
break;
}
h0 = h0.next;
}
return h1.next;
}
}
```
[22. 链表中倒数第 k 个节点](https://leetcode-cn.com/problems/lian-biao-zhong-dao-shu-di-kge-jie-dian-lcof/)
```java
@ -263,4 +292,3 @@ public class Solution {
}
}
```

Loading…
Cancel
Save