题目
1 class Solution { 2 public: 3 int flag = 0; 4 bool isUnivalTree(TreeNode* root){ 5 isUnivalTree1(root,root->val); 6 if(flag == 0) return true; 7 else return false; 8 } 9 void isUnivalTree1(TreeNode* root,int tmp) { 10 if(root!=NULL){ 11 isUnivalTree1(root->left,tmp); 12 if(root->val != tmp) flag = 1; 13 isUnivalTree1(root->right,tmp); 14 15 } 16 } 17 };