当前位置:网站首页>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]
边栏推荐
- Oracle triggers
- 50. Pow(x, n). O(logN) Sol
- The code generator has deoptimised the styling of xx/typescript.js as it exceeds the max of 500kb
- How to reverse a string fromCharCode? - How to reverse String. fromCharCode?
- 链表之双指针(快慢指针,先后指针,首尾指针)
- The countdown to the launch of metaverse ape is hot
- 鏈錶之雙指針(快慢指針,先後指針,首尾指針)
- ESP32 hosted
- Calculation method of boundary IOU
- Pl/sql basic case
猜你喜欢
Lesson 1: serpentine matrix
Qtquick3d real time reflection
我把开源项目alinesno-cloud-service关闭了
Metaverse Ape上线倒计时,推荐活动火爆进行
What if the files on the USB flash disk cannot be deleted? Win11 unable to delete U disk file solution tutorial
谷歌地图案例
Matlab draws a cute fat doll
Oracle advanced query
The difference between MVVM and MVC
The countdown to the launch of metaverse ape is hot
随机推荐
I closed the open source project alinesno cloud service
When the industrial Internet era is truly mature, we will look at the emergence of a series of new industrial giants
How can easycvr cluster deployment solve the massive video access and concurrency requirements in the project?
Alternating merging strings of leetcode simple questions
了解 Android Kotlin 中 DataStore 的基本概念以及为什么应该停止在 Android 中使用 SharedPreferences
Metasploit(msf)利用ms17_010(永恒之蓝)出现Encoding::UndefinedConversionError问题
Unique occurrence times of leetcode simple questions
Three "factions" in the metauniverse
C language - structural basis
Solutions for unexplained downtime of MySQL services
The new content of the text component can be added through the tag_ Config set foreground and background colors
Talking about MySQL index
The difference between MVVM and MVC
FBO and RBO disappeared in webgpu
Metaverse Ape上线倒计时,推荐活动火爆进行
如何快速体验OneOS
Binary tree (III) -- heap sort optimization, top k problem
Win11缺少dll文件怎么办?Win11系统找不到dll文件修复方法
数据泄露怎么办?'华生·K'7招消灭安全威胁
Web3为互联网带来了哪些改变?