随笔分类 -  algorithm

摘要:https://leetcode.cn/problems/min-cost-climbing-stairs/ ![image](https://img2023.cnblogs.com/blog/2927465/202305/2927465-20230520103150715-1161115656.p 阅读全文
posted @ 2023-05-20 11:16 E_sheep 阅读(8) 评论(0) 推荐(0) 编辑
摘要:#include <iostream> #include <cstring> #include <algorithm> #include <cstdio> using namespace std; int a[10]; int main() { for (int i = 0; i <= 2; i + 阅读全文
posted @ 2022-08-14 11:16 E_sheep 阅读(28) 评论(0) 推荐(0) 编辑
摘要:###通过数组进行线性递推 用空间换时间是确实比递归要快很多 #include <iostream> #include <cstring> #include <algorithm> #include<cstdio> using namespace std; int main() { long lon 阅读全文
posted @ 2022-08-07 00:56 E_sheep 阅读(139) 评论(0) 推荐(0) 编辑
摘要:递归的写法 第一种写法—朴素DFS求解 时间复杂度O(2^n) int fib(long long x) { if(x==1) return 1; if (x==2) return 1; return fib(x-1)+ fib(x-2); } 递归写法的劣势在于计算到第40个之后速度就会肉眼可见的 阅读全文
posted @ 2022-07-30 13:09 E_sheep 阅读(21) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示