llllmz

导航

2024年3月11日

96. 不同的二叉搜索树c

摘要: int numTrees(int n) { int* dp=(int*)malloc(sizeof(int)*(n+3)); for(int i=0;i<n+3;i++) dp[i]=0; dp[0]=1,dp[1]=1; for(int i=2;i<=n;i++){ for(int j=1;j<= 阅读全文

posted @ 2024-03-11 23:41 神奇的萝卜丝 阅读(34) 评论(0) 推荐(0)

343. 整数拆分c

摘要: 关键就在于,分还是不分是个问题。 int max(int i,int j){ if(i>j) return i; return j; } int integerBreak(int n) { int* dp=(int*)malloc(sizeof(int)*(n+4)); dp[0]=0,dp[1]= 阅读全文

posted @ 2024-03-11 22:00 神奇的萝卜丝 阅读(20) 评论(0) 推荐(0)

63. 不同路径 IIc

摘要: 难点在初始化。 int uniquePathsWithObstacles(int** obstacleGrid, int obstacleGridSize, int* obstacleGridColSize) { if(obstacleGrid[0][0]==1) return 0; int m=o 阅读全文

posted @ 2024-03-11 21:18 神奇的萝卜丝 阅读(18) 评论(0) 推荐(0)

62. 不同路径c

摘要: int uniquePaths(int m, int n) { long** dp=(long**)malloc(sizeof(long*)*(m+10)); for(int i=0;i<m+10;i++) dp[i]=(long*)malloc(sizeof(long)*(n+3)); for(i 阅读全文

posted @ 2024-03-11 21:01 神奇的萝卜丝 阅读(20) 评论(0) 推荐(0)

746. 使用最小花费爬楼梯c

摘要: int min(int i,int j){ if(i<j) return i; return j; } int minCostClimbingStairs(int* cost, int costSize) { int* dp=(int*)malloc(sizeof(int)*(costSize+3) 阅读全文

posted @ 2024-03-11 20:41 神奇的萝卜丝 阅读(17) 评论(0) 推荐(0)

70. 爬楼梯c

摘要: 还有什么比作对题且快更爽的呢。 int max(int i,int j){ if(i>j) return i; return j; } int climbStairs(int n) { int* dp=(int*)malloc(sizeof(int)*(n+3)); dp[0]=0,dp[1]=1, 阅读全文

posted @ 2024-03-11 20:34 神奇的萝卜丝 阅读(16) 评论(0) 推荐(0)

509. 斐波那契数c

摘要: 贪心后面几道区间的题目写的我想吐。先写动态规划 int fib(int n){ int* t=(int*)malloc(sizeof(int)*(n+10)); t[0]=0,t[1]=1; for(int i=2;i<=n;i++){ t[i]=t[i-1]+t[i-2]; } return t[ 阅读全文

posted @ 2024-03-11 20:18 神奇的萝卜丝 阅读(13) 评论(0) 推荐(0)

406. 根据身高重建队列c

摘要: 折磨折磨,写错一个参数,找半天。 /** * Return an array of arrays of size *returnSize. * The sizes of the arrays are returned as *returnColumnSizes array. * Note: Both 阅读全文

posted @ 2024-03-11 16:24 神奇的萝卜丝 阅读(9) 评论(0) 推荐(0)

860. 柠檬水找零c

摘要: 优先找10块,因为5块更重要。 bool lemonadeChange(int* bills, int billsSize) { int cash[21]={0}; for(int i=0;i<billsSize;i++){ if(bills[i]==5){ cash[5]++; }else if( 阅读全文

posted @ 2024-03-11 15:20 神奇的萝卜丝 阅读(14) 评论(0) 推荐(0)

134. 加油站c

摘要: ji、 假设26号复试的话,只有15天复习了。 争取一个星期刷完代码随想录,最后一个星期来准备英语和重刷。 int canCompleteCircuit(int* gas, int gasSize, int* cost, int costSize) { int sum=0; int* oil=(in 阅读全文

posted @ 2024-03-11 14:38 神奇的萝卜丝 阅读(18) 评论(0) 推荐(0)