Open AIRSATM opened 1 month ago
Alternative var:(^-^) class Solution { public: bool checkTree(TreeNode* root) { int res = root->val; int left_res = root->left->val; int right_res = root->right->val; bool tes = (res == left_res + right_res)? true : false; return tes; } };
class Solution { public: bool checkTree(TreeNode* root) { if (root->left->val + root->right->val != root->val) return false; else return true; } };