llllmz

导航

2024年3月12日

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

摘要: bool backspaceCompare(char* s, char* t) { int ns=strlen(s),nt=strlen(t); int head=0,tail=0; int n1=0,n2=0; while(tail<ns){ if(head==0&&s[tail]=='#'){ 阅读全文

posted @ 2024-03-12 22:52 神奇的萝卜丝 阅读(4) 评论(0) 推荐(0)

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

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

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

367. 有效的完全平方数c

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

posted @ 2024-03-12 20:21 神奇的萝卜丝 阅读(6) 评论(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)/2; if(nums[mid] < target){ 阅读全文

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

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

摘要: /** * Note: The returned array must be malloced, assume caller calls free(). */ int change(char c){ return c-'a'; } bool judge(char* s,int head,int ta 阅读全文

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

15. 三数之和c

摘要: 回溯写了个超时了。这里写得树层去重还是值得借鉴得。 /** * Return an array of arrays of size *returnSize. * The sizes of the arrays are returned as *returnColumnSizes array. * N 阅读全文

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

11. 盛最多水的容器c

摘要: int maxArea(int* height, int heightSize) { int max=0; int head=0,tail=heightSize-1; while(head<tail){ int sum; if(height[head]<height[tail]){ sum=heig 阅读全文

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

283. 移动零c

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

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

416. 分割等和子集c

摘要: 22号就要复试了,专业课,英语都还没搞,我的吗,先每天刷10道旧题在刷新题把。 int max(int i,int j){ if(i>j) return i; return j; } bool canPartition(int* nums, int numsSize) { int sum=0; fo 阅读全文

posted @ 2024-03-12 14:57 神奇的萝卜丝 阅读(4) 评论(0) 推荐(0)

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

摘要: 背包问题。 #include<stdio.h> #include<stdlib.h> int max(int i,int j){ if(i>j) return i; return j; } int main(){ int n1,n2; scanf("%d %d\n",&n1,&n2); int* v 阅读全文

posted @ 2024-03-12 10:32 神奇的萝卜丝 阅读(4) 评论(0) 推荐(0)