当前位置:网站首页>513. Find the value in the lower left corner of the tree
513. Find the value in the lower left corner of the tree
2022-07-05 22:30:00 【aJupyter】

# 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: Optional[TreeNode]) -> int:
''' Level traversal + The nodes with uniform depth are put into an array + Returns the first value of the last array '''
q = [root]
while q:
length = len(q)
tem = []
for _ in range(length):
node = q.pop(0)
tem.append(node.val)
if node.left:q.append(node.left)
if node.right:q.append(node.right)
return tem[0]
边栏推荐
- 如何创建线程
- Metaverse Ape获Negentropy Capital种子轮融资350万美元
- Comment développer un plug - in d'applet
- 笔记本电脑蓝牙怎么用来连接耳机
- Editor extensions in unity
- Sparse array [matrix]
- All expansion and collapse of a-tree
- Unique occurrence times of leetcode simple questions
- 解决thinkphp启动时“No input file specified”的问题
- Win11 runs CMD to prompt the solution of "the requested operation needs to be promoted"
猜你喜欢

Win11缺少dll文件怎么办?Win11系统找不到dll文件修复方法

Calculation method of boundary IOU

Post-90s tester: "after joining Ali, this time, I decided not to change jobs."

2022 Software Test Engineer salary increase strategy, how to reach 30K in three years

Lesson 1: serpentine matrix

Usage Summary of scriptable object in unity

Metaverse Ape获Negentropy Capital种子轮融资350万美元

Common interview questions of redis factory

How to quickly experience oneos

航海日答题小程序之航海知识竞赛初赛
随机推荐
Distance from point to line intersection and included angle of line
Navigation day answer applet: preliminary competition of navigation knowledge competition
[groovy] groovy dynamic language features (automatic type inference of function arguments in groovy | precautions for function dynamic parameters)
Pl/sql basic case
Damn, window in ie open()
The countdown to the launch of metaverse ape is hot
How to create a thread
Usage Summary of scriptable object in unity
Sparse array [matrix]
C language - structural basis
A trip to Suzhou during the Dragon Boat Festival holiday
南京:全面启用商品房买卖电子合同
Metaverse ape received $3.5 million in seed round financing from negentropy capital
Common interview questions of redis factory
【无标题】
IIC bus realizes client device
笔记本电脑蓝牙怎么用来连接耳机
分布式解决方案选型
Alternating merging strings of leetcode simple questions
从 1.5 开始搭建一个微服务框架——日志追踪 traceId