diff --git a/docs/notes/pics/_u4ECE_u5C3E_u5230_u5934_u6253_1548293773431.gif b/docs/notes/pics/_u4ECE_u5C3E_u5230_u5934_u6253_1548293773431.gif new file mode 100644 index 00000000..c8744a8c Binary files /dev/null and b/docs/notes/pics/_u4ECE_u5C3E_u5230_u5934_u6253_1548293773431.gif differ diff --git a/docs/notes/pics/_u4ECE_u5C3E_u5230_u5934_u6253_1548293972480.gif b/docs/notes/pics/_u4ECE_u5C3E_u5230_u5934_u6253_1548293972480.gif new file mode 100644 index 00000000..1587890c Binary files /dev/null and b/docs/notes/pics/_u4ECE_u5C3E_u5230_u5934_u6253_1548293972480.gif differ diff --git a/docs/notes/pics/_u4ECE_u5C3E_u5230_u5934_u6253_1548294571338.gif b/docs/notes/pics/_u4ECE_u5C3E_u5230_u5934_u6253_1548294571338.gif new file mode 100644 index 00000000..f2c3dce7 Binary files /dev/null and b/docs/notes/pics/_u4ECE_u5C3E_u5230_u5934_u6253_1548294571338.gif differ diff --git a/docs/notes/pics/_u4ECE_u5C3E_u5230_u5934_u6253_1548295232667.gif b/docs/notes/pics/_u4ECE_u5C3E_u5230_u5934_u6253_1548295232667.gif new file mode 100644 index 00000000..312fea60 Binary files /dev/null and b/docs/notes/pics/_u4ECE_u5C3E_u5230_u5934_u6253_1548295232667.gif differ diff --git a/docs/notes/剑指 offer 题解.md b/docs/notes/剑指 offer 题解.md index 6c61ccec..1184cb0e 100644 --- a/docs/notes/剑指 offer 题解.md +++ b/docs/notes/剑指 offer 题解.md @@ -246,12 +246,14 @@ public String replaceSpace(StringBuffer str) { 从尾到头反过来打印出每个结点的值。 -

+

## 解题思路 ### 使用栈 +

+ ```java public ArrayList printListFromTailToHead(ListNode listNode) { Stack stack = new Stack<>(); @@ -268,6 +270,8 @@ public ArrayList printListFromTailToHead(ListNode listNode) { ### 使用递归 +

+ ```java public ArrayList printListFromTailToHead(ListNode listNode) { ArrayList ret = new ArrayList<>(); @@ -288,6 +292,8 @@ public ArrayList printListFromTailToHead(ListNode listNode) { - 头结点是在头插法中使用的一个额外节点,这个节点不存储值; - 第一个节点就是链表的第一个真正存储值的节点。 +

+ ```java public ArrayList printListFromTailToHead(ListNode listNode) { // 头插法构建逆序链表 @@ -309,20 +315,6 @@ public ArrayList printListFromTailToHead(ListNode listNode) { } ``` -### 使用 Collections.reverse() - -```java -public ArrayList printListFromTailToHead(ListNode listNode) { - ArrayList ret = new ArrayList<>(); - while (listNode != null) { - ret.add(listNode.val); - listNode = listNode.next; - } - Collections.reverse(ret); - return ret; -} -``` - # 7. 重建二叉树 [NowCoder](https://www.nowcoder.com/practice/8a19cbe657394eeaac2f6ea9b0f6fcf6?tpId=13&tqId=11157&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking) diff --git a/docs/pics/_u4ECE_u5C3E_u5230_u5934_u6253_1548293773431.gif b/docs/pics/_u4ECE_u5C3E_u5230_u5934_u6253_1548293773431.gif new file mode 100644 index 00000000..c8744a8c Binary files /dev/null and b/docs/pics/_u4ECE_u5C3E_u5230_u5934_u6253_1548293773431.gif differ diff --git a/docs/pics/_u4ECE_u5C3E_u5230_u5934_u6253_1548293972480.gif b/docs/pics/_u4ECE_u5C3E_u5230_u5934_u6253_1548293972480.gif new file mode 100644 index 00000000..1587890c Binary files /dev/null and b/docs/pics/_u4ECE_u5C3E_u5230_u5934_u6253_1548293972480.gif differ diff --git a/docs/pics/_u4ECE_u5C3E_u5230_u5934_u6253_1548294571338.gif b/docs/pics/_u4ECE_u5C3E_u5230_u5934_u6253_1548294571338.gif new file mode 100644 index 00000000..f2c3dce7 Binary files /dev/null and b/docs/pics/_u4ECE_u5C3E_u5230_u5934_u6253_1548294571338.gif differ diff --git a/docs/pics/_u4ECE_u5C3E_u5230_u5934_u6253_1548295232667.gif b/docs/pics/_u4ECE_u5C3E_u5230_u5934_u6253_1548295232667.gif new file mode 100644 index 00000000..312fea60 Binary files /dev/null and b/docs/pics/_u4ECE_u5C3E_u5230_u5934_u6253_1548295232667.gif differ