Skip to content

Commit ff96252

Browse files
committed
优化文档
1 parent cc9bc94 commit ff96252

File tree

5 files changed

+20
-52
lines changed

5 files changed

+20
-52
lines changed

Diff for: docs/0000-data-structure-list.adoc

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515

1616
详情见 xref:0000-09-monotonic-stack.adoc[Monotonic Stack 单调栈]
1717

18+
=== 其他技巧
19+
20+
. 将链表做成环,比如 xref:0061-rotate-list.adoc[61. Rotate List]。
21+
1822

1923

2024
== 参考资料

Diff for: docs/0061-rotate-list.adoc

+5-32
Original file line numberDiff line numberDiff line change
@@ -32,41 +32,14 @@ image::images/0061-1.png[{image_attr}]
3232

3333
这个环形解题法很赞!
3434

35-
== 参考资料
36-
37-
. https://leetcode-cn.com/problems/rotate-list/solution/xuan-zhuan-lian-biao-by-leetcode/[旋转链表 - 旋转链表 - 力扣(LeetCode)^]
38-
39-
40-
Given a linked list, rotate the list to the right by _k_ places, where _k_ is non-negative.
41-
42-
*Example 1:*
43-
44-
[subs="verbatim,quotes,macros"]
45-
----
46-
*Input:* 1->2->3->4->5->NULL, k = 2
47-
*Output:* 4->5->1->2->3->NULL
48-
*Explanation:*
49-
rotate 1 steps to the right: 5->1->2->3->4->NULL
50-
rotate 2 steps to the right: 4->5->1->2->3->NULL
51-
----
52-
53-
*Example 2:*
54-
55-
[subs="verbatim,quotes,macros"]
56-
----
57-
*Input:* 0->1->2->NULL, k = 4
58-
*Output:* `2->0->1->NULL`
59-
*Explanation:*
60-
rotate 1 steps to the right: 2->0->1->NULL
61-
rotate 2 steps to the right: 1->2->0->NULL
62-
rotate 3 steps to the right: `0->1->2->NULL`
63-
rotate 4 steps to the right: `2->0->1->NULL`
64-
----
65-
66-
6735
[[src-0061]]
6836
[{java_src_attr}]
6937
----
7038
include::{sourcedir}/_0061_RotateList.java[tag=answer]
7139
----
7240

41+
== 参考资料
42+
43+
. https://leetcode-cn.com/problems/rotate-list/solution/xuan-zhuan-lian-biao-by-leetcode/[旋转链表 - 旋转链表 - 力扣(LeetCode)^]
44+
45+

Diff for: docs/0092-reverse-linked-list-ii.adoc

+5-20
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ Output: 1->4->3->2->5->NULL
2323

2424
最后再将三个拼接在一起。
2525

26+
[[src-0092]]
27+
[{java_src_attr}]
28+
----
29+
include::{sourcedir}/_0092_ReverseLinkedListII.java[tag=answer]
30+
----
2631

2732
== 思考题
2833

@@ -32,23 +37,3 @@ Output: 1->4->3->2->5->NULL
3237

3338
. https://leetcode-cn.com/problems/reverse-linked-list-ii/solution/fan-zhuan-lian-biao-ii-by-leetcode/[反转链表 II - 反转链表 II - 力扣(LeetCode)^]
3439

35-
36-
Reverse a linked list from position _m_ to _n_. Do it in one-pass.
37-
38-
*Note: *1 ≤ _m_ ≤ _n_ ≤ length of list.
39-
40-
*Example:*
41-
42-
[subs="verbatim,quotes,macros"]
43-
----
44-
*Input:* 1->2->3->4->5->NULL, _m_ = 2, _n_ = 4
45-
*Output:* 1->4->3->2->5->NULL
46-
----
47-
48-
49-
[[src-0092]]
50-
[{java_src_attr}]
51-
----
52-
include::{sourcedir}/_0092_ReverseLinkedListII.java[tag=answer]
53-
----
54-

Diff for: src/main/java/com/diguage/algo/leetcode/_0061_RotateList.java

+3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ public class _0061_RotateList {
2424
* Memory Usage: 38.8 MB, less than 46.55% of Java online submissions for Rotate List.
2525
*
2626
* Copy from: https://leetcode-cn.com/problems/rotate-list/solution/xuan-zhuan-lian-biao-by-leetcode/[旋转链表 - 旋转链表 - 力扣(LeetCode)]
27+
*
28+
* @author D瓜哥 · https://www.diguage.com
29+
* @since 2020-02-01 23:11
2730
*/
2831
public ListNode rotateRight(ListNode head, int k) {
2932
if (Objects.isNull(head) || Objects.isNull(head.next) || k == 0) {

Diff for: src/main/java/com/diguage/algo/leetcode/_0092_ReverseLinkedListII.java

+3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ public class _0092_ReverseLinkedListII {
2121
/**
2222
* Runtime: 0 ms, faster than 100.00% of Java online submissions for Reverse Linked List II.
2323
* Memory Usage: 36.6 MB, less than 11.36% of Java online submissions for Reverse Linked List II.
24+
*
25+
* @author D瓜哥 · https://www.diguage.com
26+
* @since 2020-02-05 22:46
2427
*/
2528
public ListNode reverseBetween(ListNode head, int m, int n) {
2629
if (m == n) {

0 commit comments

Comments
 (0)