1
class Solution {
2
public:
3
bool recur(TreeNode *root, int value) {
4
if (root == NULL) return true;
5
if (root->val != value) {
6
return false;
7
}
8
return recur(root->left, value) && recur(root->right, value);
9
}
10
bool isUnivalTree(TreeNode *root) {
11
if (root == NULL) return true;
12
int value = root->val;
13
return recur(root, value);
14
}
15
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0