Skip to content

Commit

Permalink
Time: 46 ms (87.08%) | Memory: 49.4 MB (8.14%) - LeetSync
Browse files Browse the repository at this point in the history
  • Loading branch information
ShatilKhan committed Feb 26, 2024
1 parent 2447027 commit b1b1d4e
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions 100-same-tree/same-tree.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* Definition for a binary tree node.
* function TreeNode(val, left, right) {
* this.val = (val===undefined ? 0 : val)
* this.left = (left===undefined ? null : left)
* this.right = (right===undefined ? null : right)
* }
*/
/**
* @param {TreeNode} p
* @param {TreeNode} q
* @return {boolean}
*/
var isSameTree = function(p, q) {
if(!p & !q) return true;
if(!p || !q) return false;
return p.val === q.val && isSameTree(p.left, q.left) && isSameTree(p.right, q.right);
};

0 comments on commit b1b1d4e

Please sign in to comment.