摘要: 实际就是求斐波那契数列 int numWays(int n){ if (n == 0 || n == 1) return 1; int prepre = 1; int pre = 1; int curr = 0; for (int i = 2; i <= n; i++) { curr = prepr 阅读全文
posted @ 2020-08-17 17:40 温暖了寂寞 阅读(250) 评论(0) 推荐(0) 编辑
摘要: int height(struct TreeNode* root) { if (root == NULL) { return 0; } else { return fmax(height(root->left), height(root->right)) + 1; } } bool isBalanc 阅读全文
posted @ 2020-08-17 16:09 温暖了寂寞 阅读(73) 评论(0) 推荐(0) 编辑
摘要: int maxProfit(int* prices, int pricesSize){ int ans = 0; if(pricesSize>=2) { //交易日不满两天直接返回0 int max = prices[pricesSize-1]; //将max初始化为最后一天的值 int profi 阅读全文
posted @ 2020-08-17 10:43 温暖了寂寞 阅读(286) 评论(0) 推荐(0) 编辑