摘要: 二叉树的中序遍历,没啥好说的/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) :... 阅读全文
posted @ 2015-03-14 15:16 SprayT 阅读(94) 评论(0) 推荐(0) 编辑
摘要: /* 卡特兰数,只记得递推公式, h(n) = h(n-1)*(4*n-2)/(n+1), h(n) = C(2*n,n)/(n+1), h(n) = C(2*n,n) - C(2*n,n+1);*/class Solution {public: int C(int n... 阅读全文
posted @ 2015-03-14 15:08 SprayT 阅读(82) 评论(0) 推荐(0) 编辑
摘要: 我竟然先做的前一题,无语了/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : ... 阅读全文
posted @ 2015-03-14 14:30 SprayT 阅读(97) 评论(0) 推荐(0) 编辑
摘要: 竟然c语言都不支持,而且vector实在是不熟,各种run error,题目也比较闹心,竟然要倒过来输出。我的做法:先求二叉树的最大深度,然后倒过来dfs一下~/** * Definition for binary tree * struct TreeNode { * int val; ... 阅读全文
posted @ 2015-03-14 14:19 SprayT 阅读(149) 评论(0) 推荐(0) 编辑
摘要: /* int *plusOne(int *digits, int len, int *newLen) 感觉很坑,用c做的时候一直run error而且newLen这个参数有用?*/class Solution {public: vector plusOne(vector &digi... 阅读全文
posted @ 2015-03-14 13:03 SprayT 阅读(83) 评论(0) 推荐(0) 编辑
摘要: /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; *... 阅读全文
posted @ 2015-03-14 12:10 SprayT 阅读(68) 评论(0) 推荐(0) 编辑