llllmz

导航

2024年3月17日

459. 重复的子字符串c

摘要: void build(char* s,int* next,int n){ next[0]=-1; int i=1,j=-1; while(i<n){ if(j 1||s[j]==s[i-1]){ next[i]=j+1; j++; i++; }else{ j=next[j]; } } for(int 阅读全文

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

46. 携带研究材料(第六期模拟笔试)

摘要: #include<stdio.h> #include<stdlib.h> int max(int i,int j){ if(i>j) return i; return j; } int main(){ int m,n; scanf("%d %d\n",&m,&n); int* value=(int* 阅读全文

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

96. 不同的二叉搜索树c

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

posted @ 2024-03-17 19:53 神奇的萝卜丝 阅读(14) 评论(0) 推荐(0)

63. 不同路径 IIc

摘要: int uniquePathsWithObstacles(int** obstacleGrid, int obstacleGridSize, int* obstacleGridColSize) { if(obstacleGridSize==0) return 0; int m=obstacleGri 阅读全文

posted @ 2024-03-17 19:42 神奇的萝卜丝 阅读(26) 评论(0) 推荐(0)

62. 不同路径c

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

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

70. 爬楼梯c

摘要: int climbStairs(int n) { int* dp=(int*)malloc(sizeof(int)*(n+4)); dp[0]=1,dp[1]=1; for(int i=2;i<=n;i++){ dp[i]=dp[i-1]+dp[i-2]; } return dp[n]; } 阅读全文

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

509. 斐波那契数c

摘要: int fib(int n){ int* dp=(int*)malloc(sizeof(int)*(n+4)); dp[0]=0,dp[1]=1; for(int i=2;i<=n;i++){ dp[i]=dp[i-1]+dp[i-2]; } return dp[n]; } 阅读全文

posted @ 2024-03-17 16:14 神奇的萝卜丝 阅读(13) 评论(0) 推荐(0)

435. 无重叠区间c

摘要: typedef struct node{ int left; int right; }bounds; int cmp(const void* a,const void* b){ bounds* x=(bounds*)a; bounds* y=(bounds*)b; if(x->right > y-> 阅读全文

posted @ 2024-03-17 16:12 神奇的萝卜丝 阅读(13) 评论(0) 推荐(0)

452. 用最少数量的箭引爆气球c

摘要: typedef struct node{ int left; int right; }bounds; int cmp(const void* a,const void* b){ bounds* x=(bounds*)a; bounds* y=(bounds*)b; if(x->right >y->r 阅读全文

posted @ 2024-03-17 15:23 神奇的萝卜丝 阅读(12) 评论(0) 推荐(0)

406. 根据身高重建队列c

摘要: /** * Return an array of arrays of size *returnSize. * The sizes of the arrays are returned as *returnColumnSizes array. * Note: Both returned array a 阅读全文

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

860. 柠檬水找零c

摘要: bool lemonadeChange(int* bills, int billsSize) { int money[21]={0}; for(int i=0;i<billsSize;i++){ if(bills[i]==5){ money[5]++; }else if(bills[i]==10){ 阅读全文

posted @ 2024-03-17 12:40 神奇的萝卜丝 阅读(15) 评论(0) 推荐(0)