MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / isSameTree

Method isSameTree

CPP/Trees/Same Tree.cpp:14–20  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12class Solution {
13public:
14 bool isSameTree(TreeNode* p, TreeNode* q) {
15 if(p==NULL || q==NULL)
16 {
17 return (p==q);
18 }
19 return ((p->val==q->val) && isSameTree(p->left,q->left) && isSameTree(p->right,q->right));
20 }
21};

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected