[LeetCode] - 965. 单值二叉树
作者:互联网
题目
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* struct TreeNode *left;
* struct TreeNode *right;
* };
*/
bool isUnivalTree(struct TreeNode* root){
if (root==NULL)
{
return true;
}
if (root->left && root->left->val!= root->val)
{
return false;
}
if (root->right && root->right->val!= root->val)
{
return false;
}
return isUnivalTree(root->right) && isUnivalTree(root->left);
}
标签:965,right,TreeNode,struct,val,二叉树,return,root,LeetCode 来源: https://blog.csdn.net/zhaozhenyu123/article/details/121239207