Skip to content

Commit

Permalink
Root Equals Sum of Children (saadfareed#73)
Browse files Browse the repository at this point in the history
* Find the Winner of the Circular Game Problem No.1823

* Root Equals Sum of Children

Peoblem No.2236
  • Loading branch information
hussainiftikhar5242 authored Oct 16, 2022
1 parent 2e6d95c commit 968da15
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions C++/Root Equals Sum of Children.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Name: Hussain Iftikhar
// UserName: hussainiftikhar5242
// Approach: first sum the left and right node of tree and then check the parent node is equal to the Parent node
class Solution {
public:
bool checkTree(TreeNode* root) {
int sum=0;
sum = root->left->val + root->right->val;
if(sum == root->val)
{
return true;
}
return false;

}
};

0 comments on commit 968da15

Please sign in to comment.