MCPcopy Create free account
hub / github.com/neetcode-gh/leetcode / isSameNode

Function isSameNode

javascript/0100-same-tree.js:71–82  ·  view source on GitHub ↗
(p, q)

Source from the content-addressed store, hash-verified

69};
70
71const isSameNode = (p, q) => {
72 const isBaseCase = !(p || q);
73 if (isBaseCase) return true;
74
75 const isBalanced = p && q;
76 if (!isBalanced) return false;
77
78 const isSame = p.val === q.val;
79 if (!isSame) return false;
80
81 return true;
82};
83
84const isSame = (p, q) =>
85 isSameNode(p, q) &&

Callers 2

isSameTreeFunction · 0.85
isSameFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected