File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -16,3 +16,24 @@ const isSameTree = function(p, q) {
16
16
if ( p == null || q == null || p . val !== q . val ) return false
17
17
return isSameTree ( p . left , q . left ) && isSameTree ( p . right , q . right )
18
18
} ;
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
+ } ;
You can’t perform that action at this time.
0 commit comments