摘要: class Solution {public: bool isBalanced(TreeNode *root) { if(root==NULL)return true; int left=depth(root->left); int right=depth(root->right); if(abs(left-right)>1)return false; return isBalanced(root->left)&&isBalanced(root->right); } int depth(Tre... 阅读全文
posted @ 2013-04-16 23:53 代码改变未来 阅读(131) 评论(0) 推荐(0) 编辑
摘要: class Solution {public: string addBinary(string a, string b) { reverse(a.begin(),a.end()); reverse(b.begin(),b.end()); string a1,a2; if(a.length()>=b.length()) { a1=a; a2=b; } else { a1=b; a2=a; ... 阅读全文
posted @ 2013-04-16 21:50 代码改变未来 阅读(164) 评论(0) 推荐(0) 编辑