标签:tco code root val bsp false leetcode col data
1 class Solution 2 { 3 public: 4 bool PreOrderTraverse (TreeNode* T,int data) 5 { 6 if(T) 7 { 8 if(T->val!=data) 9 return false; 10 if(!PreOrderTraverse (T -> left,data)) 11 return false; 12 if(!PreOrderTraverse (T -> right,data)) 13 return false ; 14 } 15 return true; 16 } 17 bool isUnivalTree(TreeNode* root) 18 { 19 return PreOrderTraverse(root,root->val); 20 } 21 };
Leetcode-965 Univalued Binary Tree(单值二叉树)
标签:tco code root val bsp false leetcode col data
原文地址:https://www.cnblogs.com/Asurudo/p/10199718.html