llllmz

导航

2024年2月27日

76. 最小覆盖子串C

摘要: int hash(char c){ return c-'A'+1; } bool judge_Same(int a[],int b[]){ for(int i=0;i<200;i++){ if(b[i]!=0 && b[i]>a[i]) return false; } return true ; } 阅读全文

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

904. 水果成篮C

摘要: int totalFruit(int* fruits, int fruitsSize) { if(fruitsSize<=2) return fruitsSize; int a[2]={-1,-1};//蓝子空 int max=0,n=1; int head=0, tail=0;//从head摘到t 阅读全文

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

209. 长度最小的子数组C

摘要: 滑动窗口的妙用!! int minSubArrayLen(int target, int* nums, int numsSize) { int sum=nums[0];//区间head到tail的和 int head=0,tail=0; int minn=numsSize; int tag=0; i 阅读全文

posted @ 2024-02-27 15:04 神奇的萝卜丝 阅读(10) 评论(0) 推荐(0)

977. 有序数组的平方

摘要: 学习了下用qsort解决。 /** * Note: The returned array must be malloced, assume caller calls free(). */ int cmp(const void* a,const void* b){ return *(int*)a-*( 阅读全文

posted @ 2024-02-27 13:39 神奇的萝卜丝 阅读(11) 评论(0) 推荐(0)

844. 比较含退格的字符串C

摘要: 这题学到了很多。 malloc后要初始化。 申请字符串要N+1个单位 字符串以0结尾等等 char* final(char* s,int n){ char* tem=(char*)malloc(sizeof(char)*(n+1)); for(int i=0;i<=n;i++) { tem[i] = 阅读全文

posted @ 2024-02-27 13:15 神奇的萝卜丝 阅读(18) 评论(0) 推荐(0)