当前位置:网站首页>Leetcode 199. right view of binary tree
Leetcode 199. right view of binary tree
2022-07-28 22:55:00 【henujolly】
BfS
class Solution {
List<Integer>res=new LinkedList<>();
public List<Integer> rightSideView(TreeNode root) {
Queue<TreeNode>queue=new LinkedList<>();
if(root==null) return res;
queue.add(root);
while(!queue.isEmpty()){
int size=queue.size();
for(int i=0;i<size;i++){
TreeNode node=queue.poll();
if(node.left!=null) queue.add(node.left);
if(node.right!=null) queue.add(node.right);
if(i==size-1) res.add(node.val);
}
}
return res;
}
}
DFS
边栏推荐
- Configuration and official document of Freia library [tips]
- can‘t convert cuda:0 device type tensor to numpy. Use Tensor. cpu() to copy the tensor to host memory
- The simple neural network model based on full connection layer MLP is changed to the model based on CNN convolutional neural network
- Learning experience sharing 4: learning experience of yolov7
- Simple es highlight practice
- Console.log() console display... Solution
- C语言学习内容总结
- RuntimeError: set_ sizes_ contiguous is not allowed on a Tensor created from .data or .detach().
- ValueError: Using a target size (torch.Size([64])) that is different to the input size (torch.Size([
- OSV_ q AttributeError: ‘numpy. ndarray‘ object has no attribute ‘clone‘
猜你喜欢
![Draem+sspcab [anomaly detection: block]](/img/97/75ce235c2021b56007eecb82afe4b0.png)
Draem+sspcab [anomaly detection: block]

LTE cell search process and sch/bch design
![[3D target detection] 3dssd (II)](/img/8a/e8927cd868eb99d8880d4f199d8918.png)
[3D target detection] 3dssd (II)

Summary of common formula notes for solving problems in Higher Mathematics
![Stm32f4 serial port burning [flymcu]](/img/5b/0e35c3c58354f911631a3affd3909b.png)
Stm32f4 serial port burning [flymcu]

STM32CUBEIDE(10)----ADC在DMA模式下扫描多个通道

记录一下关于三角函数交换积分次序的一道题

Yolov5 improvement 12: replace backbone network C3 with lightweight network shufflenetv2

STM32 - memory, I2C protocol

Stm32subeide (10) -- ADC scans multiple channels in DMA mode
随机推荐
OSV-q grd_ x=grd_ x[:, :, 0:-1, :]-data_ in[:, :, 1:, :]IndexError: too many indices for tensor of d
winform跳转第二个窗体案例
Improvement 16 of yolov5: replace backbone network C3 with lightweight network pp-lcnet
Stm32subeide (10) -- ADC scans multiple channels in DMA mode
Redis related
Improvement 13 of yolov5: replace backbone network C3 with lightweight network efficientnetv2
投资1450亿欧元!欧盟17国宣布联合发展半导体技术
Differernet [anomaly detection: normalizing flow]
Shell script foundation - shell operation principle + variable and array definitions
STM32 - interrupt overview (interrupt priority)
[3D target detection] 3dssd (II)
Summary of common formula notes for solving problems in Higher Mathematics
One of the experience of solving problems with code error reporting: CUDA does not match pytorch
can‘t convert cuda:0 device type tensor to numpy. Use Tensor. cpu() to copy the tensor to host memory
软件测试工具fiddler postman jmeter charlse核心功能总结
Gd32f303 firmware library development (10) -- dual ADC polling mode scanning multiple channels
《结构学》介绍
Learning experience sharing 3: yolov5 training data set path index
Es learning directory
frontiers出版社投稿记录(附状态变化)