当前位置:网站首页>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]
边栏推荐
- MySQL服务莫名宕机的解决方案
- a-tree 树的全部展开和收起
- Sparse array [matrix]
- Usage Summary of scriptable object in unity
- Leetcode simple question check whether all characters appear the same number of times
- FBO and RBO disappeared in webgpu
- The code generator has deoptimised the styling of xx/typescript.js as it exceeds the max of 500kb
- Platform bus
- 科技云报道:算力网络,还需跨越几道坎?
- Oracle views the data size of a table
猜你喜欢
Matlab draws a cute fat doll
Three "factions" in the metauniverse
Leetcode simple question: check whether each row and column contain all integers
Nacos 的安装与服务的注册
Postman核心功能解析-参数化和测试报告
Post-90s tester: "after joining Ali, this time, I decided not to change jobs."
Lesson 1: serpentine matrix
Metasploit(msf)利用ms17_010(永恒之蓝)出现Encoding::UndefinedConversionError问题
Technology cloud report won the special contribution award for the 10th anniversary of 2013-2022 of the "cloud Ding Award" of the global cloud computing conference
Distance from point to line intersection and included angle of line
随机推荐
第一讲:蛇形矩阵
了解 Android Kotlin 中 DataStore 的基本概念以及为什么应该停止在 Android 中使用 SharedPreferences
Solutions for unexplained downtime of MySQL services
Opencv judgment points are inside and outside the polygon
点到直线的距离直线的交点及夹角
Request preview display of binary data and Base64 format data
How to quickly experience oneos
MySQL actual combat 45 lecture learning (I)
Pl/sql basic syntax
Metaverse ape received $3.5 million in seed round financing from negentropy capital
Lesson 1: serpentine matrix
U盘的文件无法删除文件怎么办?Win11无法删除U盘文件解决教程
Technology cloud report won the special contribution award for the 10th anniversary of 2013-2022 of the "cloud Ding Award" of the global cloud computing conference
Double pointeur de liste liée (pointeur rapide et lent, pointeur séquentiel, pointeur de tête et de queue)
MySQL服务莫名宕机的解决方案
记录几个常见问题(202207)
Thinkphp5.1 cross domain problem solving
Leetcode simple question: the minimum cost of buying candy at a discount
Platformio create libopencm3 + FreeRTOS project
Postman core function analysis - parameterization and test report