Definition at line 15 of file main.cpp.
◆ isSameTree()
Definition at line 18 of file main.cpp.
19 {
20 if (!p && !q)
21 return true;
22 else if ((p && !q) || (!p && q))
23 return false;
24 queue<pair<TreeNode*, TreeNode*>> nodes;
25 nodes.push({p, q});
26 while (!nodes.empty())
27 {
28 auto [pt, qt] = nodes.front();
29 nodes.pop();
30
31 if ((pt && !qt) || (!pt && qt) || pt->val != qt->val)
32 return false;
33 if (pt->left || qt->left)
34 nodes.push({pt->left, qt->left});
35 if (pt->right || qt->right)
36 nodes.push({pt->right, qt->right});
37 }
38 return true;
39 }
Referenced by main().
The documentation for this class was generated from the following file: