mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-09 19:44:45 +08:00
@ -274,8 +274,28 @@ class Solution {
|
||||
|
||||
|
||||
Python:
|
||||
|
||||
|
||||
```python
|
||||
//递归法
|
||||
# Definition for a binary tree node.
|
||||
# class TreeNode:
|
||||
# def __init__(self, val=0, left=None, right=None):
|
||||
# self.val = val
|
||||
# self.left = left
|
||||
# self.right = right
|
||||
class Solution:
|
||||
def findBottomLeftValue(self, root: TreeNode) -> int:
|
||||
depth=0
|
||||
self.res=[]
|
||||
def level(root,depth):
|
||||
if not root:return
|
||||
if depth==len(self.res):
|
||||
self.res.append([])
|
||||
self.res[depth].append(root.val)
|
||||
level(root.left,depth+1)
|
||||
level(root.right,depth+1)
|
||||
level(root,depth)
|
||||
return self.res[-1][0]
|
||||
```
|
||||
Go:
|
||||
|
||||
|
||||
@ -285,4 +305,4 @@ Go:
|
||||
* 作者微信:[程序员Carl](https://mp.weixin.qq.com/s/b66DFkOp8OOxdZC_xLZxfw)
|
||||
* B站视频:[代码随想录](https://space.bilibili.com/525438321)
|
||||
* 知识星球:[代码随想录](https://mp.weixin.qq.com/s/QVF6upVMSbgvZy8lHZS3CQ)
|
||||
<div align="center"><img src=../pics/公众号.png width=450 alt=> </img></div>
|
||||
<div align="center"><img src=../pics/公众号.png width=450 alt=> </img></div>
|
||||
|
Reference in New Issue
Block a user