Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wushizhenking
CS-Notes
提交
ebe84d53
C
CS-Notes
项目概览
wushizhenking
/
CS-Notes
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
CS-Notes
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ebe84d53
编写于
1月 24, 2019
作者:
C
CyC2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
auto commit
上级
47bccabb
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
19 addition
and
31 deletion
+19
-31
docs/notes/剑指 offer 题解.md
docs/notes/剑指 offer 题解.md
+19
-31
未找到文件。
docs/notes/剑指 offer 题解.md
浏览文件 @
ebe84d53
[
🎉 面试进阶指南已上线
](
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
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录