/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* struct TreeNode *left;
* struct TreeNode *right;
* };
*/
bool judge(struct TreeNode* proot,int tem)
{
if(proot==NULL)
return true;
if(proot->val!=tem)
{
return false;
}
return judge(proot->left,proot->val)&&judge(proot->right,proot->val);
}
bool isUnivalTree(struct TreeNode* root) {
return judge(root,root->val);
}
单值二叉树(力扣第965题)
最新推荐文章于 2024-09-14 18:52:56 发布