摘要: 1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *next; 6 * ListNode(int x) : val(x), next(NULL) {} 7 * }; 8 */ 9 class Solution {10 public:11 ListNode* cut(ListNode *head){12 int count=0;13 ListNode *temp=head;1... 阅读全文
posted @ 2013-12-14 21:25 蓝兔子 阅读(143) 评论(0) 推荐(0) 编辑
摘要: 写了个笨程序,总是出错。给出错误,仅以为戒 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *right; 7 * TreeNode(int x) : val(x), left(NULL), right(NULL) {} 8 * }; 9 */10 class Solution {11 public:12 bool isSameTree(TreeNode *p, TreeNode... 阅读全文
posted @ 2013-12-14 20:17 蓝兔子 阅读(110) 评论(0) 推荐(0) 编辑
摘要: 通过给妹妹讲解复习C的知识,自己也学习了一下,mark。1.1 #include2 int main()3 {4 int x=10,y=10,i;5 for(i=0;x>8;y=++i)6 printf("%d,%d",x--,y);7 return 0;8 } View Code printf的参数是从后面开始压栈的,就是说看计算结果的时候先看y,再看x--,再执行“printf()”的打印功能2.这个程序计算s=1+1/2+1/3+1/3+.....+1/10 1 #include 2 int main() 3 { 4 int n; 5... 阅读全文
posted @ 2013-12-14 16:44 蓝兔子 阅读(158) 评论(0) 推荐(0) 编辑
摘要: 计算二叉树深度:leetCode1. 递归调用/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */class Solution {public: int maxDepth(TreeNode *root) { if(root==NULL) return 0; ... 阅读全文
posted @ 2013-12-14 13:31 蓝兔子 阅读(697) 评论(0) 推荐(0) 编辑