摘要:
class Solution {public: bool isValidBST(TreeNode *root) { stack<TreeNode *>s; TreeNode *p=root; int pre=INT_MIN; while(p||!s.empty()) { while(p) { s.push(p); p=p->left; } if(!s.empty()... 阅读全文
摘要:
class Solution {public:vectorv;int num; int sumNumbers(TreeNode *root) { num=0; v.clear(); sum(root); int sum=0; for(int i=0;ival; if(root->left==NULL&&root->right==NULL) { v.push_back(num); } if(root->lef... 阅读全文
摘要:
脑子犯傻了。。class Solution {public: bool isSymmetric(TreeNode *root) { if(root==NULL) return true; return ischeck(root->left,root->right); } bool ischeck(TreeNode *p,TreeNode *q) { if(p==NULL&&q==NULL)return true; if(p==NULL&&q!=NULL)return false; ... 阅读全文