摘要:
二叉树的中序遍历,没啥好说的/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) :... 阅读全文
摘要:
/* 卡特兰数,只记得递推公式, 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... 阅读全文
摘要:
我竟然先做的前一题,无语了/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : ... 阅读全文
摘要:
竟然c语言都不支持,而且vector实在是不熟,各种run error,题目也比较闹心,竟然要倒过来输出。我的做法:先求二叉树的最大深度,然后倒过来dfs一下~/** * Definition for binary tree * struct TreeNode { * int val; ... 阅读全文
摘要:
/* int *plusOne(int *digits, int len, int *newLen) 感觉很坑,用c做的时候一直run error而且newLen这个参数有用?*/class Solution {public: vector plusOne(vector &digi... 阅读全文
摘要:
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; *... 阅读全文