摘要: /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solu 阅读全文
posted @ 2016-03-08 10:47 白天黑夜每日c 阅读(117) 评论(0) 推荐(0) 编辑
摘要: Invert a binary tree. class Solution { public: TreeNode* invertTree(TreeNode* root) { TreeNode* temp; if(root) { temp=root->left; root->left=root->rig 阅读全文
posted @ 2016-03-08 10:27 白天黑夜每日c 阅读(121) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, find its maximum depth. class Solution { public: int maxDepth(TreeNode* root) { int depth=0; if(!root) return depth; int a=maxDep 阅读全文
posted @ 2016-03-08 10:16 白天黑夜每日c 阅读(80) 评论(0) 推荐(0) 编辑