auto commit
This commit is contained in:
parent
47bccabb69
commit
ebe84d5383
|
@ -1,7 +1,5 @@
|
|||
[🎉 面试进阶指南已上线](https://xiaozhuanlan.com/CyC2018)
|
||||
<!-- GFM-TOC -->
|
||||
* [1. 前言](#1-前言)
|
||||
* [2. 实现 Singleton](#2-实现-singleton)
|
||||
* [3. 数组中重复的数字](#3-数组中重复的数字)
|
||||
* [4. 二维数组中的查找](#4-二维数组中的查找)
|
||||
* [5. 替换空格](#5-替换空格)
|
||||
|
@ -82,16 +80,6 @@
|
|||
<!-- GFM-TOC -->
|
||||
|
||||
|
||||
# 1. 前言
|
||||
|
||||
本文内容可在微信小程序中阅读:
|
||||
|
||||
<div align="center"> <img src="pics/gh_a68199af85d6_258_20_282_29.jpg"/> </div><br>
|
||||
|
||||
# 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) {
|
|||
|
||||
## 解题思路
|
||||
|
||||
### 使用栈
|
||||
|
||||
<div align="center"> <img src="pics/_u4ECE_u5C3E_u5230_u5934_u6253_1548293773431.gif" width="500px"> </div><br>
|
||||
|
||||
```java
|
||||
public ArrayList<Integer> printListFromTailToHead(ListNode listNode) {
|
||||
Stack<Integer> stack = new Stack<>();
|
||||
while (listNode != null) {
|
||||
stack.add(listNode.val);
|
||||
listNode = listNode.next;
|
||||
}
|
||||
ArrayList<Integer> ret = new ArrayList<>();
|
||||
while (!stack.isEmpty())
|
||||
ret.add(stack.pop());
|
||||
return ret;
|
||||
}
|
||||
```
|
||||
|
||||
### 使用递归
|
||||
|
||||
<div align="center"> <img src="pics/_u4ECE_u5C3E_u5230_u5934_u6253_1548294571338.gif" width="200px"> </div><br>
|
||||
|
@ -292,7 +262,7 @@ public ArrayList<Integer> printListFromTailToHead(ListNode listNode) {
|
|||
- 头结点是在头插法中使用的一个额外节点,这个节点不存储值;
|
||||
- 第一个节点就是链表的第一个真正存储值的节点。
|
||||
|
||||
<div align="center"> <img src="pics/_u4ECE_u5C3E_u5230_u5934_u6253_1548295232667.gif"/> </div><br>
|
||||
<div align="center"> <img src="pics/_u4ECE_u5C3E_u5230_u5934_u6253_1548295232667.gif" width="300px"> </div><br>
|
||||
|
||||
```java
|
||||
public ArrayList<Integer> printListFromTailToHead(ListNode listNode) {
|
||||
|
@ -315,6 +285,24 @@ public ArrayList<Integer> printListFromTailToHead(ListNode listNode) {
|
|||
}
|
||||
```
|
||||
|
||||
### 使用栈
|
||||
|
||||
<div align="center"> <img src="pics/_u4ECE_u5C3E_u5230_u5934_u6253_1548293773431.gif" width="500px"> </div><br>
|
||||
|
||||
```java
|
||||
public ArrayList<Integer> printListFromTailToHead(ListNode listNode) {
|
||||
Stack<Integer> stack = new Stack<>();
|
||||
while (listNode != null) {
|
||||
stack.add(listNode.val);
|
||||
listNode = listNode.next;
|
||||
}
|
||||
ArrayList<Integer> 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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user