2236. Root Equals Sum of Children ¶ Time: $O(1)$ Space: $O(1)$ C++JavaPython 1 2 3 4 5 6class Solution { public: bool checkTree(TreeNode* root) { return root->val == root->left->val + root->right->val; } }; 1 2 3 4 5class Solution { public boolean checkTree(TreeNode root) { return root.val == root.left.val + root.right.val; } } 1 2 3class Solution: def checkTree(self, root: TreeNode | None) -> bool: return root.val == root.left.val + root.right.val