Skip to content

Commit be6fe18

Browse files
committed
update: 101
1 parent a76b835 commit be6fe18

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

‎README.md

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ This is the solutions collection of my LeetCode submissions, most of them are pr
5252
|88|[ Merge Sorted Array](https://leetcode.com/problems/merge-sorted-array/) | [JavaScript](./src/merge-sorted-array/res.js)|Medium|
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|
55+
|101|[Symmetric Tree](https://leetcode.com/problems/symmetric-tree/) | [JavaScript](./src/symmetric-tree/res.js)|Easy|
5556
|120|[Triangle](https://leetcode.com/problems/triangle/) | [JavaScript](./src/triangle/res.js)|Medium|
5657
|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|
5758
|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|

‎src/symmetric-tree/res.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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 {boolean}
11+
*/
12+
var isSymmetric = function(root) {
13+
const isMirror = (t1, t2) => {
14+
if (t1 == null && t2 == null) return true;
15+
if (t1 == null || t2 == null) return false;
16+
17+
return t1.val === t2.val && isMirror(t1.left, t2.right) && isMirror(t1.right, t2.left);
18+
}
19+
20+
return isMirror(root, root);
21+
};

0 commit comments

Comments
 (0)