Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦境迷离
Cs Summary Reflection
提交
9ea276c8
C
Cs Summary Reflection
项目概览
梦境迷离
/
Cs Summary Reflection
9 个月 前同步成功
通知
4
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
Cs Summary Reflection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
9ea276c8
编写于
6月 15, 2020
作者:
L
laozhang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add python 513 and python 222
上级
28a8aad6
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
46 addition
and
0 deletion
+46
-0
python-leetcode/README.md
python-leetcode/README.md
+2
-0
python-leetcode/solution/tree/leetcode_222_.py
python-leetcode/solution/tree/leetcode_222_.py
+18
-0
python-leetcode/solution/tree/leetcode_513_.py
python-leetcode/solution/tree/leetcode_513_.py
+26
-0
未找到文件。
python-leetcode/README.md
浏览文件 @
9ea276c8
...
...
@@ -53,6 +53,8 @@
39.
[
先序遍历构造二叉树
](
./solution/tree/leetcode_1008_.py
)
40.
[
二叉搜索树中第K小的元素
](
./solution/tree/leetcode_230_.py
)
41.
[
删除给定值的叶子节点
](
./solution/tree/leetcode_1325_.py
)
42.
[
找树左下角的值
](
./solution/tree/leetcode_513_.py
)
43.
[
完全二叉树的节点个数
](
./solution/tree/leetcode_222_.py
)
...
...
python-leetcode/solution/tree/leetcode_222_.py
0 → 100644
浏览文件 @
9ea276c8
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# coding=utf-8
"""
222. 完全二叉树的节点个数
"""
from
solution
import
TreeNode
class
Solution
:
def
countNodes
(
self
,
root
:
TreeNode
)
->
int
:
if
not
root
:
return
0
a
=
self
.
countNodes
(
root
.
left
)
b
=
self
.
countNodes
(
root
.
right
)
return
a
+
b
+
1
python-leetcode/solution/tree/leetcode_513_.py
0 → 100644
浏览文件 @
9ea276c8
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# coding=utf-8
"""
513. 找树左下角的值
"""
from
solution
import
TreeNode
class
Solution
:
def
findBottomLeftValue
(
self
,
root
:
TreeNode
)
->
int
:
list
=
[]
def
helper
(
root
:
TreeNode
,
k
:
int
):
nonlocal
list
if
root
:
if
k
>
len
(
list
):
temp
=
[]
temp
.
append
(
root
.
val
)
list
.
append
(
temp
)
else
:
list
[
k
-
1
].
append
(
root
.
val
)
helper
(
root
.
left
,
k
+
1
)
helper
(
root
.
right
,
k
+
1
)
helper
(
root
,
1
)
return
list
[
-
1
][
0
]
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录