当前位置:网站首页>JS force deduction brush question 102 Sequence traversal of binary tree
JS force deduction brush question 102 Sequence traversal of binary tree
2022-04-23 13:56:00 【Candy_ Rainbow_】
var levelOrder = function(root) {
let rear = [];// Traversal queue
let answers = [];// Two dimensional array
if(!root)return answers;// A special case
rear.push(root);// Root in line
while(rear.length > 0){
let answer = [];// Traversal layer by layer
let len = rear.length;// The queue length will change , Record the following
for(let i = 0; i < len; i++){
let tmp = rear.shift();
answer.push(tmp.val);
if(tmp.left)rear.push(tmp.left);
if(tmp.right)rear.push(tmp.right);
}
answers.push(answer);
}
return answers;
};
版权声明
本文为[Candy_ Rainbow_]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231353588806.html
边栏推荐
- 函数只执行第一次的执行一次 once函数
- Test the time required for Oracle library to create an index with 7 million data in a common way
- Leetcode? The first common node of two linked lists
- leetcode--380.O(1) 时间插入、删除和获取随机元素
- About note 1
- SQL learning window function
- AtCoder Beginner Contest 248C Dice Sum (生成函数)
- [code analysis (5)] communication efficient learning of deep networks from decentralized data
- Oracle database recovery data
- Oracle modify default temporary tablespace
猜你喜欢

What is the difference between blue-green publishing, rolling publishing and gray publishing?

聯想拯救者Y9000X 2020

Basic SQL query and learning

Kettle--控件解析

Oracle defines self incrementing primary keys through triggers and sequences, and sets a scheduled task to insert a piece of data into the target table every second
![Three characteristics of volatile keyword [data visibility, prohibition of instruction rearrangement and no guarantee of operation atomicity]](/img/ec/b1e99e0f6e7d1ef1ce70eb92ba52c6.png)
Three characteristics of volatile keyword [data visibility, prohibition of instruction rearrangement and no guarantee of operation atomicity]

Search ideas and cases of large amount of Oracle redo log

Handling of high usage of Oracle undo

大专的我,闭关苦学 56 天,含泪拿下阿里 offer,五轮面试,六个小时灵魂拷问

OSS cloud storage management practice (polite experience)
随机推荐
Lenovo Saver y9000x 2020
China creates vast research infrastructure to support ambitious climate goals
UML Unified Modeling Language
[code analysis (5)] communication efficient learning of deep networks from decentralized data
Atcoder beginer contest 248c dice sum (generating function)
零拷貝技術
UNIX final exam summary -- for direct Department
About me
初探 Lambda Powertools TypeScript
PG library checks the name
Choreographer全解析
Small case of web login (including verification code login)
函数只执行第一次的执行一次 once函数
Interval query through rownum
Dolphin scheduler source package Src tar. GZ decompression problem
Ora-600 encountered in Oracle environment [qkacon: fjswrwo]
Analysis of redo log generated by select command
Question bank and answer analysis of the 2022 simulated examination of the latest eight members of Jiangxi construction (quality control)
Oracle index status query and index reconstruction
RAC environment error reporting ora-00239: timeout waiting for control file enqueue troubleshooting