Skip to content

Commit 15318b4

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 86d39c8 + e530ece commit 15318b4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+85
-76
lines changed

README.md

+3-3

README_EN.md

+3-3
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

index.html

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@
99
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
1010
<link rel="stylesheet" href="//unpkg.com/docsify/lib/themes/vue.css">
1111
<link rel="stylesheet" href="//unpkg.com/[email protected]/dist/style.css" />
12-
<link rel="icon" type="image/png" sizes="32x32" href="img/favicon-32x32.png">
13-
<link rel="icon" type="image/png" sizes="16x16" href="img/favicon-16x16.png">
12+
<link rel="icon" type="image/png" sizes="32x32" href="images/favicon-32x32.png">
13+
<link rel="icon" type="image/png" sizes="16x16" href="images/favicon-16x16.png">
1414
</head>
1515

1616
<body>
17-
<div id="app">本系列知识由 Doocs 开源社区原创发布</div>
17+
<div id="app">本系列知识由 Doocs 技术社区原创发布</div>
1818
<script>
1919
window.$docsify = {
2020
name: 'leetcode',
21-
logo: '/img/doocs-leetcode.png',
21+
logo: '/images/doocs-leetcode.png',
2222
search: [
2323
'/','/solution/','/lcof/','lcci/'
2424
],

lcof/面试题18. 删除链表的节点/README.md

+14-14

lcof/面试题18. 删除链表的节点/Solution.java

+11-8
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
11
/**
2-
* Definition for singly-linked list. public class ListNode { int val; ListNode
3-
* next; ListNode(int x) { val = x; } }
2+
* Definition for singly-linked list.
3+
* public class ListNode {
4+
* int val;
5+
* ListNode next;
6+
* ListNode(int x) { val = x; }
7+
* }
48
*/
59
class Solution {
610
public ListNode deleteNode(ListNode head, int val) {
7-
ListNode pre = new ListNode(0);
8-
pre.next = head;
9-
ListNode dummy = pre, p = head;
11+
ListNode dummy = new ListNode(0);
12+
dummy.next = head;
13+
ListNode pre = dummy, p = head;
1014
while (p != null) {
1115
if (p.val == val) {
1216
pre.next = p.next;
1317
break;
14-
} else {
15-
pre = p;
16-
p = p.next;
1718
}
19+
pre = p;
20+
p = p.next;
1821
}
1922
return dummy.next;
2023
}

lcof/面试题18. 删除链表的节点/Solution.py

+4-7
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,14 @@
33
# def __init__(self, x):
44
# self.val = x
55
# self.next = None
6-
76
class Solution:
87
def deleteNode(self, head: ListNode, val: int) -> ListNode:
9-
pre = ListNode(0)
10-
pre.next = head
11-
dummy = pre
12-
p = head
8+
dummy = ListNode(0)
9+
dummy.next = head
10+
pre, p = dummy, head
1311
while p:
1412
if p.val == val:
1513
pre.next = p.next
1614
break
17-
else:
18-
pre, p = p, p.next
15+
pre, p = p, p.next
1916
return dummy.next

lcof/面试题22. 链表中倒数第k个节点/README.md

+5

lcof/面试题24. 反转链表/README.md

+16-14

lcof/面试题24. 反转链表/Solution.java

+4-7
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,14 @@
88
*/
99
class Solution {
1010
public ListNode reverseList(ListNode head) {
11-
if (head == null) {
12-
return head;
13-
}
14-
ListNode dummy = new ListNode(0);
11+
ListNode pre = null;
1512
ListNode p = head;
1613
while (p != null) {
1714
ListNode q = p.next;
18-
p.next = dummy.next;
19-
dummy.next = p;
15+
p.next = pre;
16+
pre = p;
2017
p = q;
2118
}
22-
return dummy.next;
19+
return pre;
2320
}
2421
}

lcof/面试题24. 反转链表/Solution.py

+4-7
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,10 @@
66

77
class Solution:
88
def reverseList(self, head: ListNode) -> ListNode:
9-
if not head:
10-
return head
11-
dummy = ListNode(0)
12-
p = head
9+
pre, p = None, head
1310
while p:
1411
q = p.next
15-
p.next = dummy.next
16-
dummy.next = p
12+
p.next = pre
13+
pre = p
1714
p = q
18-
return dummy.next
15+
return pre

lcof/面试题25. 合并两个排序的链表/README.md

+3

lcof/面试题35. 复杂链表的复制/README.md

+3-3

lcof/面试题36. 二叉搜索树与双向链表/README.md

+2-2

lcof/面试题52. 两个链表的第一个公共节点/README.md

+9-4

0 commit comments

Comments
 (0)