Skip to content

Commit

Permalink
bug fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Copyes committed Jun 14, 2020
1 parent 516b510 commit 95fa890
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ScriptOJ/isBalanced.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var isBalanced = function(root) {
if(node === null) return 0;
let left = dfs(node.left);
let right = dfs(node.right);
if(Math.abs(left, right) > 1) {
if(Math.abs(left-right) > 1) {
ans = false;
}
return Math.max(left, right) + 1;
Expand Down
23 changes: 23 additions & 0 deletions ScriptOJ/isSymmetric.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* Definition for a binary tree node.
* function TreeNode(val) {
* this.val = val;
* this.left = this.right = null;
* }
*/
/**
* @param {TreeNode} root
* @return {boolean}
*/
var isSymmetric = function(root) {
if(root == null) return true;

function recur(L, R) {
if(L === null && R === null) return true;
if(L === null || R === null || L.val !== R.val) return false;

return recur(L.left, R.right) && recur(L.right, R.left);
}

return recur(root.left, root.right);
};
1 change: 1 addition & 0 deletions Solutions/leetcode-solution/二叉树.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,4 @@ var postorderTraversal = function(root) {
### 题目列表
- [x] 112. 路径总和 https://leetcode-cn.com/problems/path-sum/
- [x] 面试题27. 二叉树的镜像 https://leetcode-cn.com/problems/er-cha-shu-de-jing-xiang-lcof/
- [x] 面试题28. 对称的二叉树 https://leetcode-cn.com/problems/dui-cheng-de-er-cha-shu-lcof/

0 comments on commit 95fa890

Please sign in to comment.