Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit040e17e

Browse files
committed
update: 102
1 parentbe6fe18 commit040e17e

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

‎README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ This is the solutions collection of my LeetCode submissions, most of them are pr
5353
|91|[Decode Ways](https://leetcode.com/problems/decode-ways/)|[JavaScript](./src/decode-ways/res.js)|Medium|
5454
|93|[Restore IP Addresses](https://leetcode.com/problems/restore-ip-addresses/)|[JavaScript](./src/restore-ip-addresses/res.js)|Medium|
5555
|101|[Symmetric Tree](https://leetcode.com/problems/symmetric-tree/)|[JavaScript](./src/symmetric-tree/res.js)|Easy|
56+
|102|[Binary Tree Level Order Traversal](https://leetcode.com/problems/binary-tree-level-order-traversal/)|[JavaScript](./src/binary-tree-level-order-traversal/res.js)|Medium|
5657
|120|[Triangle](https://leetcode.com/problems/triangle/)|[JavaScript](./src/triangle/res.js)|Medium|
5758
|121|[Best Time to Buy and Sell Stock](https://leetcode.com/problems/best-time-to-buy-and-sell-stock/)|[JavaScript](./src/best-time-to-buy-and-sell-stock/res.js)|Easy|
5859
|122|[Best Time to Buy and Sell Stock II](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/)|[JavaScript](./src/best-time-to-buy-and-sell-stock-ii/res.js)|Easy|
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* Definition for a binary tree node.
3+
* function TreeNode(val) {
4+
* this.val = val;
5+
* this.left = this.right = null;
6+
* }
7+
*/
8+
/**
9+
*@param {TreeNode} root
10+
*@return {number[][]}
11+
*/
12+
varlevelOrder=function(root){
13+
if(!root)return[];
14+
15+
letqueue=[root];
16+
constres=[];
17+
18+
while(queue.length){
19+
consttempQ=[];
20+
consttempR=[];
21+
queue.map(e=>{
22+
if(e.val!==undefined)tempR.push(e.val);
23+
24+
if(e.left){
25+
tempQ.push(e.left);
26+
}
27+
if(e.right){
28+
tempQ.push(e.right);
29+
}
30+
});
31+
queue=tempQ;
32+
res.push(tempR);
33+
}
34+
35+
returnres;
36+
};

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp