Skip to content

Commit

Permalink
Merge pull request #1 from ravimenariya/ravimenariya-patch-1
Browse files Browse the repository at this point in the history
Create 21-Nov_identical_tree.cpp
  • Loading branch information
ravimenariya authored Nov 21, 2023
2 parents 299e6f2 + c95af2a commit e85fb2f
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions 11-2023(nov)/21-Nov_identical_tree.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class Solution
{
public:
//Function to check if two trees are identical.
bool isIdentical(Node *r1, Node *r2)
{
//Your Code here
if (!r1 && !r2) {
return true;
}

if (r1 && r2 && r1->data == r2->data) {
return isIdentical(r1->left, r2->left) &&
isIdentical(r1->right, r2->right);
}

return false;
}
};

0 comments on commit e85fb2f

Please sign in to comment.