Skip to content

Commit a682549

Browse files
authored
Update 100-same-tree.js
1 parent 72ba1b9 commit a682549

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

100-same-tree.js

+21
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,24 @@ const isSameTree = function(p, q) {
1616
if(p == null || q == null || p.val !== q.val) return false
1717
return isSameTree(p.left, q.left) && isSameTree(p.right, q.right)
1818
};
19+
20+
// another
21+
22+
/**
23+
* Definition for a binary tree node.
24+
* function TreeNode(val, left, right) {
25+
* this.val = (val===undefined ? 0 : val)
26+
* this.left = (left===undefined ? null : left)
27+
* this.right = (right===undefined ? null : right)
28+
* }
29+
*/
30+
/**
31+
* @param {TreeNode} p
32+
* @param {TreeNode} q
33+
* @return {boolean}
34+
*/
35+
const isSameTree = function(p, q) {
36+
if(p == null || q == null) return p === q
37+
if(p.val !== q.val) return false
38+
return isSameTree(p.left, q.left) && isSameTree(p.right, q.right)
39+
};

0 commit comments

Comments
 (0)