From ebe84d53837a6a2ce7833a1eb092f6f5e36d6a4e Mon Sep 17 00:00:00 2001 From: CyC2018 <1029579233@qq.com> Date: Thu, 24 Jan 2019 10:12:13 +0800 Subject: [PATCH] auto commit --- ...214\207 offer \351\242\230\350\247\243.md" | 50 +++++++------------ 1 file changed, 19 insertions(+), 31 deletions(-) diff --git "a/docs/notes/\345\211\221\346\214\207 offer \351\242\230\350\247\243.md" "b/docs/notes/\345\211\221\346\214\207 offer \351\242\230\350\247\243.md" index 1184cb0e..709bbb98 100644 --- "a/docs/notes/\345\211\221\346\214\207 offer \351\242\230\350\247\243.md" +++ "b/docs/notes/\345\211\221\346\214\207 offer \351\242\230\350\247\243.md" @@ -1,7 +1,5 @@ [🎉 面试进阶指南已上线](https://xiaozhuanlan.com/CyC2018) -* [1. 前言](#1-前言) -* [2. 实现 Singleton](#2-实现-singleton) * [3. 数组中重复的数字](#3-数组中重复的数字) * [4. 二维数组中的查找](#4-二维数组中的查找) * [5. 替换空格](#5-替换空格) @@ -82,16 +80,6 @@ -# 1. 前言 - -本文内容可在微信小程序中阅读: - -

- -# 2. 实现 Singleton - -[单例模式](设计模式.md) - # 3. 数组中重复的数字 [NowCoder](https://www.nowcoder.com/practice/623a5ac0ea5b4e5f95552655361ae0a8?tpId=13&tqId=11203&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking) @@ -250,24 +238,6 @@ public String replaceSpace(StringBuffer str) { ## 解题思路 -### 使用栈 - -

- -```java -public ArrayList printListFromTailToHead(ListNode listNode) { - Stack stack = new Stack<>(); - while (listNode != null) { - stack.add(listNode.val); - listNode = listNode.next; - } - ArrayList ret = new ArrayList<>(); - while (!stack.isEmpty()) - ret.add(stack.pop()); - return ret; -} -``` - ### 使用递归

@@ -292,7 +262,7 @@ public ArrayList printListFromTailToHead(ListNode listNode) { - 头结点是在头插法中使用的一个额外节点,这个节点不存储值; - 第一个节点就是链表的第一个真正存储值的节点。 -

+

```java public ArrayList printListFromTailToHead(ListNode listNode) { @@ -315,6 +285,24 @@ public ArrayList printListFromTailToHead(ListNode listNode) { } ``` +### 使用栈 + +

+ +```java +public ArrayList printListFromTailToHead(ListNode listNode) { + Stack stack = new Stack<>(); + while (listNode != null) { + stack.add(listNode.val); + listNode = listNode.next; + } + ArrayList ret = new ArrayList<>(); + while (!stack.isEmpty()) + ret.add(stack.pop()); + 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) -- GitLab