本文整理汇总了C++中Solution::IsBalanced_Solution方法的典型用法代码示例。如果您正苦于以下问题:C++ Solution::IsBalanced_Solution方法的具体用法?C++ Solution::IsBalanced_Solution怎么用?C++ Solution::IsBalanced_Solution使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Solution
的用法示例。
在下文中一共展示了Solution::IsBalanced_Solution方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
TreeNode* tree = (TreeNode*)malloc(sizeof(TreeNode));
TreeNode* p = tree;
tree->val = 0;
for(int i = 1; i < 10; i+=2){
TreeNode* left = (TreeNode*)malloc(sizeof(TreeNode));
TreeNode* right = (TreeNode*)malloc(sizeof(TreeNode));
left->val = i;
right->val = i+1;
p->left = left;
p->right = right;
if((i-1)%4 == 0){
p = left;
}else{
p = right;
}
}
Solution s = Solution();
bool r = s.IsBalanced_Solution(tree);
string result = r==1?"true":"false";
cout<<result<<endl;
}
示例2: main
int main()
{
Solution a;
TreeNode* pRoot = new TreeNode(1);
pRoot->left = new TreeNode(2);
pRoot->right = new TreeNode(3);
pRoot->left->left = new TreeNode(4);
pRoot->left->right = new TreeNode(5);
//pRoot->left->right->left = new TreeNode(6);
cout << a.IsBalanced_Solution(pRoot) << ' ';
DestoryTree(pRoot);
system("pause");
return 0;
}