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

Commit ca696fa

Browse files
update: 111
1 parent 040e17e commit ca696fa

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

‎README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ This is the solutions collection of my LeetCode submissions, most of them are pr
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|
5656
|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|
57+
|107|[Binary Tree Level Order Traversal II](https://leetcode.com/problems/binary-tree-level-order-traversal-ii/) | [JavaScript](./src/binary-tree-level-order-traversal-ii/res.js)|Easy|
5758
|120|[Triangle](https://leetcode.com/problems/triangle/) | [JavaScript](./src/triangle/res.js)|Medium|
5859
|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|
5960
|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: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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+
var minDepth = function(root) {
13+
if (!root) return 0;
14+
15+
let queue = [root];
16+
let res = 1;
17+
18+
while(queue.length) {
19+
const tempQ = [];
20+
let isNull = false;
21+
22+
queue.map(e => {
23+
if (!e.left && !e.right) isNull = true;
24+
25+
e.left && tempQ.push(e.left);
26+
e.right && tempQ.push(e.right);
27+
});
28+
queue = tempQ;
29+
if (isNull) {
30+
break;
31+
} else {
32+
res += 1;
33+
}
34+
}
35+
36+
return res;
37+
};

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /