llllmz

导航

2024年3月18日

904. 水果成篮c

摘要: int totalFruit(int* fruits, int fruitsSize) { int lanzi[2]={-1,-1}; if(fruitsSize<=2) return fruitsSize; int max=0,count=0; int head=0,tail=0; while(t 阅读全文

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

209. 长度最小的子数组c

摘要: int minSubArrayLen(int target, int* nums, int numsSize) { int head=0,tail=0,sum=nums[0]; long min=LONG_MAX; while(tail<numsSize){ if(sum>=target){ if( 阅读全文

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

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

摘要: bool backspaceCompare(char* s, char* t) { int ns=strlen(s),nt=strlen(t); int heads=0,headt=0,index=0; while(index<ns){ if(s[index]!='#'){ s[heads++]=s 阅读全文

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

26. 删除有序数组中的重复项c

摘要: int removeDuplicates(int* nums, int numsSize) { int head=0,index=0; while(index<numsSize){ if(index!=0 && nums[index]!=nums[index-1]){ nums[head++]=nu 阅读全文

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

367. 有效的完全平方数c

摘要: bool isPerfectSquare(int num) { if(num==1) return true; int head=0,tail=num-1; while(head<=tail){ int mid=head+(tail-head)/2; long long temp=pow(mid,2 阅读全文

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

35. 搜索插入位置c

摘要: int searchInsert(int* nums, int numsSize, int target) { int head=0,tail=numsSize-1; while(head<=tail){ int mid=head+(tail-head)/2; if(nums[mid]==targe 阅读全文

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

438. 找到字符串中所有字母异位词c

摘要: /** * Note: The returned array must be malloced, assume caller calls free(). */ bool judge(int* a,int* b){ for(int i=0;i<27;i++){ if(a[i]<b[i]) return 阅读全文

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

15. 三数之和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-18 16:27 神奇的萝卜丝 阅读(13) 评论(0) 推荐(0)

283. 移动零c

摘要: void moveZeroes(int* nums, int numsSize) { int head=0,index=0; while(index<numsSize){ if(nums[index]!=0){ nums[head++]=nums[index]; } index++; } for(; 阅读全文

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