llllmz

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

03 2024 档案

2605. 从两个数字数组里生成最小数字c
摘要:int minNumber(int* nums1, int nums1Size, int* nums2, int nums2Size) { int min=INT_MAX; for(int i=0;i<nums1Size;i++){ int sum=0; for(int j=0;j<nums2Siz 阅读全文

posted @ 2024-03-22 11:08 神奇的萝卜丝 阅读(7) 评论(0) 推荐(0) 编辑

2367. 算术三元组的数目c
摘要:int count; void dfs(int* nums,int numsSize,int diff,int index,int pre,int nowcount){ if(index>numsSize || nowcount>3) return; if(index==numsSize && no 阅读全文

posted @ 2024-03-22 10:53 神奇的萝卜丝 阅读(5) 评论(0) 推荐(0) 编辑

2652. 倍数求和c
摘要:int sumOfMultiples(int n){ int* dp=(int*)malloc(sizeof(int)*(n+4)); dp[1]=0,dp[2]=0; for(int i=3;i<=n;i++){ if(i%3==0 || i%5==0 || i%7==0 ){ dp[i]=dp[ 阅读全文

posted @ 2024-03-22 10:29 神奇的萝卜丝 阅读(5) 评论(0) 推荐(0) 编辑

2798. 满足目标工作时长的员工数目c
摘要:int numberOfEmployeesWhoMetTarget(int* hours, int hoursSize, int target){ int count=0; for(int i=0;i<hoursSize;i++){ if(hours[i] >= target) count++; } 阅读全文

posted @ 2024-03-22 10:24 神奇的萝卜丝 阅读(3) 评论(0) 推荐(0) 编辑

2917. 找出数组中的 K-or 值c
摘要:int findKOr(int* nums, int numsSize, int k) { if(k>numsSize) return 0; int sum=0; for(int i=0;i<31;i++){ int count=0; for(int j=0;j<numsSize;j++){ int 阅读全文

posted @ 2024-03-22 10:22 神奇的萝卜丝 阅读(5) 评论(0) 推荐(0) 编辑

2465. 不同的平均值数目c
摘要:int cmp(const void* a,const void* b){ return *(int*)a-*(int*)b; } int distinctAverages(int* nums, int numsSize) { if(numsSize <=2) return 1; qsort(num 阅读全文

posted @ 2024-03-22 10:08 神奇的萝卜丝 阅读(2) 评论(0) 推荐(0) 编辑

90. 子集 IIc
摘要:/** * 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-21 20:55 神奇的萝卜丝 阅读(2) 评论(0) 推荐(0) 编辑

125. 验证回文串c
摘要:bool judge(char c){ if(c>='a'&& c<='z' || c>='A' && c<='Z' || c>='0' && c<='9' ) return true; return false; } bool isPalindrome(char* s) { int n=strle 阅读全文

posted @ 2024-03-21 20:38 神奇的萝卜丝 阅读(7) 评论(0) 推荐(0) 编辑

234. 回文链表c
摘要:/** * Definition for singly-linked list. * struct ListNode { * int val; * struct ListNode *next; * }; */ struct ListNode* pre; bool judge(struct ListN 阅读全文

posted @ 2024-03-21 20:27 神奇的萝卜丝 阅读(4) 评论(0) 推荐(0) 编辑

66. 加一c
摘要:/** * Note: The returned array must be malloced, assume caller calls free(). */ void reverse(int* s,int n){ int head=0,tail=n-1; while(head<=tail){ in 阅读全文

posted @ 2024-03-21 20:24 神奇的萝卜丝 阅读(6) 评论(0) 推荐(0) 编辑

67. 二进制求和c
摘要:int max(int i,int j){ if(i>j) return i; return j; } void reverse(char* s,int head,int tail){ while(head<=tail){ char c=s[head]; s[head]=s[tail]; s[tai 阅读全文

posted @ 2024-03-21 20:16 神奇的萝卜丝 阅读(6) 评论(0) 推荐(0) 编辑

14. 最长公共前缀c
摘要:bool judge(char* s1,char* s2,int n){ for(int i=0;i<n;i++){ if(s1[i]!=s2[i]) return false; } return true; } char* longestCommonPrefix(char** strs, int 阅读全文

posted @ 2024-03-21 19:47 神奇的萝卜丝 阅读(2) 评论(0) 推荐(0) 编辑

121. 买卖股票的最佳时机c
摘要:int max(int i,int j){ if(i>j) return i; return j; } int maxProfit(int* prices, int pricesSize) { int** dp=(int**)malloc(sizeof(int*)*pricesSize); for( 阅读全文

posted @ 2024-03-21 19:41 神奇的萝卜丝 阅读(1) 评论(0) 推荐(0) 编辑

131. 分割回文串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-21 19:30 神奇的萝卜丝 阅读(5) 评论(0) 推荐(0) 编辑

40. 组合总和 IIc
摘要:/** * 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-21 19:01 神奇的萝卜丝 阅读(5) 评论(0) 推荐(0) 编辑

39. 组合总和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-21 18:58 神奇的萝卜丝 阅读(2) 评论(0) 推荐(0) 编辑

17. 电话号码的字母组合c
摘要:/** * Note: The returned array must be malloced, assume caller calls free(). */ char temp[10]; char c[10][5]={" "," ","abc","def","ghi","jkl","mno","p 阅读全文

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

77. 组合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-21 17:39 神奇的萝卜丝 阅读(1) 评论(0) 推荐(0) 编辑

108. 将有序数组转换为二叉搜索树c
摘要:/** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */ struct TreeNode* bu 阅读全文

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

669. 修剪二叉搜索树c
摘要:/** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */ struct TreeNode* tr 阅读全文

posted @ 2024-03-21 17:22 神奇的萝卜丝 阅读(2) 评论(0) 推荐(0) 编辑

450. 删除二叉搜索树中的节点c
摘要:/** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */ struct TreeNode* le 阅读全文

posted @ 2024-03-21 17:10 神奇的萝卜丝 阅读(1) 评论(0) 推荐(0) 编辑

236. 二叉树的最近公共祖先c
摘要:/** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */ struct TreeNode* lo 阅读全文

posted @ 2024-03-21 16:57 神奇的萝卜丝 阅读(2) 评论(0) 推荐(0) 编辑

98. 验证二叉搜索树c
摘要:/** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */ long pre; bool inor 阅读全文

posted @ 2024-03-21 16:46 神奇的萝卜丝 阅读(3) 评论(0) 推荐(0) 编辑

257. 二叉树的所有路径c
摘要:/** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */ /** * Note: The ret 阅读全文

posted @ 2024-03-21 16:36 神奇的萝卜丝 阅读(6) 评论(0) 推荐(0) 编辑

485. 最大连续 1 的个数c
摘要:int findMaxConsecutiveOnes(int* nums, int numsSize) { int max=0,index=0,count=0; while(index<numsSize){ if(nums[index]==1){ count++; if(count>max) max 阅读全文

posted @ 2024-03-20 17:08 神奇的萝卜丝 阅读(5) 评论(0) 推荐(0) 编辑

876. 链表的中间结点c
摘要:/** * Definition for singly-linked list. * struct ListNode { * int val; * struct ListNode *next; * }; */ struct ListNode* middleNode(struct ListNode* 阅读全文

posted @ 2024-03-20 17:06 神奇的萝卜丝 阅读(3) 评论(0) 推荐(0) 编辑

面试题 17.12. BiNodec
摘要:/** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */ struct TreeNode* co 阅读全文

posted @ 2024-03-20 17:05 神奇的萝卜丝 阅读(2) 评论(0) 推荐(0) 编辑

LCR 159. 库存管理 IIIc
摘要:/** * Note: The returned array must be malloced, assume caller calls free(). */ int divide(int* stock,int head,int tail){ int t=stock[head]; while(hea 阅读全文

posted @ 2024-03-20 16:59 神奇的萝卜丝 阅读(3) 评论(0) 推荐(0) 编辑

111. 二叉树的最小深度c
摘要:/** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */ int min(int i,int j 阅读全文

posted @ 2024-03-20 16:49 神奇的萝卜丝 阅读(4) 评论(0) 推荐(0) 编辑

559. N 叉树的最大深度c
摘要:/** * Definition for a Node. * struct Node { * int val; * int numChildren; * struct Node** children; * }; */ int maxDepth(struct Node* root) { if(!roo 阅读全文

posted @ 2024-03-20 16:44 神奇的萝卜丝 阅读(3) 评论(0) 推荐(0) 编辑

1312. 让字符串成为回文串的最少插入次数c
摘要:int min; void dfs(char* s,int head,int tail, int count){ if(head>=tail){ if(count<min) min=count; return ; } if(s[head]==s[tail]){ dfs(s,head+1,tail-1 阅读全文

posted @ 2024-03-20 16:32 神奇的萝卜丝 阅读(3) 评论(0) 推荐(0) 编辑

200. 岛屿数量c
摘要:int visit[300][300]; void dfs(char** grid,int m,int n,int i,int j){ if(i>=m || j>=n) return; visit[i][j]=1; if( i+1<m && grid[i+1][j]=='1' && visit[i+ 阅读全文

posted @ 2024-03-20 16:18 神奇的萝卜丝 阅读(2) 评论(0) 推荐(0) 编辑

405. 数字转换为十六进制数c
摘要:] 不简单的题目。 char change(int n){ if(n<=9) return n+'0'; return n-10+'a'; } void reverse(char* array,int n){ int head=0,tail=n-1; while(head<=tail){ char 阅读全文

posted @ 2024-03-20 15:58 神奇的萝卜丝 阅读(7) 评论(0) 推荐(0) 编辑

102. 二叉树的层序遍历C
摘要:/** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */ /** * Return an arr 阅读全文

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

347. 前 K 个高频元素C
摘要:/** * Note: The returned array must be malloced, assume caller calls free(). */ typedef struct node{ int num; int count; }HASH; void insert(HASH* h,in 阅读全文

posted @ 2024-03-20 10:55 神奇的萝卜丝 阅读(4) 评论(0) 推荐(0) 编辑

118. 杨辉三角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-20 10:26 神奇的萝卜丝 阅读(2) 评论(0) 推荐(0) 编辑

415. 字符串相加c
摘要:void reverse(char* num1, int n){ int head=0,tail=n-1; while(head<=tail){ char c=num1[head]; num1[head]=num1[tail]; num1[tail]=c; head++; tail--; } } i 阅读全文

posted @ 2024-03-20 09:27 神奇的萝卜丝 阅读(7) 评论(0) 推荐(0) 编辑

150. 逆波兰表达式求值c
摘要:int f(int a ,int b,char c){ if(c=='+') return a+b; if(c=='-') return a-b; if(c=='/') return a/b; return a*b; } int evalRPN(char** tokens, int tokensSi 阅读全文

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

459. 重复的子字符串c
摘要:void build(int* next,char* s,int n){ next[0]=-1; int index=1,j=-1; while(index<n){ if(j 1 || s[index-1] == s[j]){ j++; next[index++]=j; }else{ j=next[ 阅读全文

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

28. 找出字符串中第一个匹配项的下标c
摘要:void bulid(int* next,char* s,int n){ next[0]=-1; int index=1,j=-1; while(index<n){ if(j 1 || s[index-1] ==s[j] ){ j++; next[index++]=j; }else{ j=next[ 阅读全文

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

142. 环形链表 II
摘要:/** * Definition for singly-linked list. * struct ListNode { * int val; * struct ListNode *next; * }; */ struct ListNode *detectCycle(struct ListNode 阅读全文

posted @ 2024-03-19 15:54 神奇的萝卜丝 阅读(2) 评论(0) 推荐(0) 编辑

76. 最小覆盖子串c
摘要:bool judge(int* s,int* t){ for(int i=0;i<200;i++){ if(s[i]<t[i]) return false; } return true; } char* minWindow(char* s, char* t) { int ns=strlen(s),n 阅读全文

posted @ 2024-03-19 15:51 神奇的萝卜丝 阅读(3) 评论(0) 推荐(0) 编辑

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 神奇的萝卜丝 阅读(2) 评论(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 神奇的萝卜丝 阅读(4) 评论(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 神奇的萝卜丝 阅读(3) 评论(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 神奇的萝卜丝 阅读(8) 评论(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 神奇的萝卜丝 阅读(0) 评论(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 神奇的萝卜丝 阅读(2) 评论(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 神奇的萝卜丝 阅读(3) 评论(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 神奇的萝卜丝 阅读(3) 评论(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 神奇的萝卜丝 阅读(3) 评论(0) 推荐(0) 编辑

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 神奇的萝卜丝 阅读(3) 评论(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 神奇的萝卜丝 阅读(13) 评论(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 神奇的萝卜丝 阅读(2) 评论(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 神奇的萝卜丝 阅读(8) 评论(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 神奇的萝卜丝 阅读(8) 评论(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 神奇的萝卜丝 阅读(5) 评论(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 神奇的萝卜丝 阅读(2) 评论(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 神奇的萝卜丝 阅读(2) 评论(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 神奇的萝卜丝 阅读(1) 评论(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 神奇的萝卜丝 阅读(3) 评论(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 神奇的萝卜丝 阅读(4) 评论(0) 推荐(0) 编辑

135. 分发糖果c
摘要:int max(int i,int j){ if(i>j) return i; return j; } int candy(int* ratings, int ratingsSize) { int* left=(int*)malloc(sizeof(int)*ratingsSize); int* r 阅读全文

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

134. 加油站c
摘要:int canCompleteCircuit(int* gas, int gasSize, int* cost, int costSize) { int sum=0,n=gasSize; for(int i=0;i<n;i++){ gas[i]=gas[i]-cost[i]; sum+=gas[i] 阅读全文

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

1005. K 次取反后最大化的数组和c
摘要:int largestSumAfterKNegations(int* nums, int numsSize, int k) { int t[201]={0}; int sum=0; for(int i=0;i<numsSize;i++){ sum+=nums[i]; t[nums[i]+100]++ 阅读全文

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

55. 跳跃游戏c
摘要:int max(int i,int j){ if(i>j) return i; return j; } bool canJump(int* nums, int numsSize) { if(numsSize==1) return true; if(nums[0]==0) return false; 阅读全文

posted @ 2024-03-16 16:36 神奇的萝卜丝 阅读(2) 评论(0) 推荐(0) 编辑

122. 买卖股票的最佳时机 IIc
摘要:int max(int i,int j){ if(i>j) return i; return j; } int maxProfit(int* prices, int pricesSize) { int** dp=(int**)malloc(sizeof(int*)*pricesSize); for( 阅读全文

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

53. 最大子数组和c
摘要:int max(int i,int j){ if(i>j) return i; return j; } int maxSubArray(int* nums, int numsSize) { int* dp=(int*)malloc(sizeof(int)*numsSize); dp[0]=nums[ 阅读全文

posted @ 2024-03-16 16:08 神奇的萝卜丝 阅读(4) 评论(0) 推荐(0) 编辑

376. 摆动序列c
摘要:int max(int i,int j){ if(i>j) return i; return j; } int wiggleMaxLength(int* nums, int numsSize){ int** dp=(int**)malloc(sizeof(int*)*numsSize); for(i 阅读全文

posted @ 2024-03-16 15:40 神奇的萝卜丝 阅读(1) 评论(0) 推荐(0) 编辑

491. 非递减子序列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-16 13:38 神奇的萝卜丝 阅读(3) 评论(0) 推荐(0) 编辑

90. 子集 IIC
摘要:/** * 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-16 13:27 神奇的萝卜丝 阅读(4) 评论(0) 推荐(0) 编辑

面试题 01.01. 判定字符是否唯一c
摘要:\ bool isUnique(char* astr){ int temp[26]={0}; for(int i=0;i<strlen(astr);i++){ temp[astr[i]-'a']++; } for(int i=0;i<26;i++){ if(temp[i]>1) return fal 阅读全文

posted @ 2024-03-15 22:51 神奇的萝卜丝 阅读(1) 评论(0) 推荐(0) 编辑

141. 环形链表c
摘要:/** * Definition for singly-linked list. * struct ListNode { * int val; * struct ListNode *next; * }; */ bool hasCycle(struct ListNode *head) { struct 阅读全文

posted @ 2024-03-15 22:26 神奇的萝卜丝 阅读(3) 评论(0) 推荐(0) 编辑

125. 验证回文串c
摘要:回文串 置逆,栈,双指针。 bool judge(char c){ if(c>='a'&&c<='z') return true; if(c>='A'&&c<='Z') return true; if(c>='0'&&c<='9') return true; return false; } bool 阅读全文

posted @ 2024-03-15 22:24 神奇的萝卜丝 阅读(7) 评论(0) 推荐(0) 编辑

136. 只出现一次的数字c
摘要:int singleNumber(int* nums, int numsSize) { int t=nums[0]; for(int i=1;i<numsSize;i++) t=t^nums[i]; return t; } 结果: 阅读全文

posted @ 2024-03-15 22:06 神奇的萝卜丝 阅读(5) 评论(0) 推荐(0) 编辑

2235. 两整数相加
摘要:int sum(int num1, int num2){ return num1+num2; } 阅读全文

posted @ 2024-03-15 21:45 神奇的萝卜丝 阅读(3) 评论(0) 推荐(0) 编辑

234. 回文链表c
摘要:/** * Definition for singly-linked list. * struct ListNode { * int val; * struct ListNode *next; * }; */ struct ListNode* pre; bool judge(struct ListN 阅读全文

posted @ 2024-03-15 21:42 神奇的萝卜丝 阅读(2) 评论(0) 推荐(0) 编辑

389. 找不同c
摘要:char findTheDifference(char* s, char* t) { int temps[26]={0}; int tempt[26]={0}; int n1=strlen(s),n2=strlen(t); for(int i=0;i<n1;i++) temps[s[i]-'a']+ 阅读全文

posted @ 2024-03-15 21:26 神奇的萝卜丝 阅读(2) 评论(0) 推荐(0) 编辑

66. 加一c
摘要:/** * Note: The returned array must be malloced, assume caller calls free(). */ void reverse(int* a,int n){ int head=0,tail=n-1; while(head<=tail){ in 阅读全文

posted @ 2024-03-15 21:23 神奇的萝卜丝 阅读(3) 评论(0) 推荐(0) 编辑

83. 删除排序链表中的重复元素c
摘要:/** * Definition for singly-linked list. * struct ListNode { * int val; * struct ListNode *next; * }; */ int pre; struct ListNode* f(struct ListNode* 阅读全文

posted @ 2024-03-15 21:01 神奇的萝卜丝 阅读(5) 评论(0) 推荐(0) 编辑

67. 二进制求和c
摘要:特好的题目,进制转化就刷它。 void reverse(char* s){ int n=strlen(s); int head=0,tail=n-1; while(head<=tail){ char t=s[head]; s[head]=s[tail]; s[tail]=t; head++; tai 阅读全文

posted @ 2024-03-15 20:37 神奇的萝卜丝 阅读(2) 评论(0) 推荐(0) 编辑

169. 多数元素c
摘要:int cmp(const void* a,const void* b){ return *(int*)a-*(int*)b; } int majorityElement(int* nums, int numsSize) { qsort(nums,numsSize,sizeof(int),cmp); 阅读全文

posted @ 2024-03-15 19:49 神奇的萝卜丝 阅读(4) 评论(0) 推荐(0) 编辑

9. 回文数c
摘要:bool isPalindrome(int x) { char c[1000]={0}; sprintf(c,"%d",x); int n=strlen(c); int head=0,tail=n-1; while(head<=tail){ if(c[head]!=c[tail]) return f 阅读全文

posted @ 2024-03-15 19:44 神奇的萝卜丝 阅读(4) 评论(0) 推荐(0) 编辑

21. 合并两个有序链表c
摘要:/** * Definition for singly-linked list. * struct ListNode { * int val; * struct ListNode *next; * }; */ struct ListNode* mergeTwoLists(struct ListNod 阅读全文

posted @ 2024-03-15 19:35 神奇的萝卜丝 阅读(7) 评论(0) 推荐(0) 编辑

14. 最长公共前缀c
摘要:char* longestCommonPrefix(char** strs, int strsSize) { int index=1,min=INT_MAX; if(strsSize==1) return strs[0]; while(index<strsSize){ int i=0; while( 阅读全文

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

13. 罗马数字转整数c
摘要:int romanToInt(char* s) { int n=strlen(s); int c[26]; c['I'-'A']=1; c['V'-'A']=5; c['X'-'A']=10; c['L'-'A']=50; c['C'-'A']=100; c['D'-'A']=500; c['M'- 阅读全文

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

121. 买卖股票的最佳时机c
摘要:int max(int i,int j){ if(i>j) return i; return j; } int maxProfit(int* prices, int pricesSize) { int** dp=(int**)malloc(sizeof(int*)*pricesSize); for( 阅读全文

posted @ 2024-03-15 17:57 神奇的萝卜丝 阅读(2) 评论(0) 推荐(0) 编辑

1768. 交替合并字符串c
摘要:char * mergeAlternately(char * word1, char * word2){ int n1=strlen(word1),n2=strlen(word2); char* temp=(char*)malloc(sizeof(char)*(n1+n2+1)); int inde 阅读全文

posted @ 2024-03-15 16:52 神奇的萝卜丝 阅读(14) 评论(0) 推荐(0) 编辑

131. 分割回文串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-15 16:39 神奇的萝卜丝 阅读(4) 评论(0) 推荐(0) 编辑

40. 组合总和 IIc
摘要:/** * 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-15 15:54 神奇的萝卜丝 阅读(1) 评论(0) 推荐(0) 编辑

39. 组合总和c
摘要:脑残了,参数传错了,debug了半天。 /** * Return an array of arrays of size *returnSize. * The sizes of the arrays are returned as *returnColumnSizes array. * Note: B 阅读全文

posted @ 2024-03-15 15:35 神奇的萝卜丝 阅读(3) 评论(0) 推荐(0) 编辑

17. 电话号码的字母组合c
摘要:/** * Note: The returned array must be malloced, assume caller calls free(). */ char c[10][10]={" "," ","abc\0","def\0","ghi\0","jkl\0","mno\0","pqrs\ 阅读全文

posted @ 2024-03-15 14:46 神奇的萝卜丝 阅读(16) 评论(0) 推荐(0) 编辑

77. 组合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-15 14:01 神奇的萝卜丝 阅读(4) 评论(0) 推荐(0) 编辑

108. 将有序数组转换为二叉搜索树c
摘要:/** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */ struct TreeNode* bu 阅读全文

posted @ 2024-03-15 13:35 神奇的萝卜丝 阅读(1) 评论(0) 推荐(0) 编辑

669. 修剪二叉搜索树c
摘要:/** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */ struct TreeNode* tr 阅读全文

posted @ 2024-03-15 13:03 神奇的萝卜丝 阅读(3) 评论(0) 推荐(0) 编辑

450. 删除二叉搜索树中的节点c
摘要:/** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */ struct TreeNode* le 阅读全文

posted @ 2024-03-14 19:39 神奇的萝卜丝 阅读(4) 评论(0) 推荐(0) 编辑

236. 二叉树的最近公共祖先c
摘要:/** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */ struct TreeNode* lo 阅读全文

posted @ 2024-03-14 19:23 神奇的萝卜丝 阅读(1) 评论(0) 推荐(0) 编辑

501. 二叉搜索树中的众数c
摘要:/** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */ /** * Note: The ret 阅读全文

posted @ 2024-03-14 16:12 神奇的萝卜丝 阅读(3) 评论(0) 推荐(0) 编辑

98. 验证二叉搜索树c
摘要:/** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */ bool inorder(struct 阅读全文

posted @ 2024-03-14 15:21 神奇的萝卜丝 阅读(4) 评论(0) 推荐(0) 编辑

617. 合并二叉树c
摘要:/** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */ struct TreeNode* me 阅读全文

posted @ 2024-03-14 15:02 神奇的萝卜丝 阅读(1) 评论(0) 推荐(0) 编辑

513. 找树左下角的值C
摘要:/** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */ int findBottomLeftV 阅读全文

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

404. 左叶子之和c
摘要:/** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */ int preorder(struct 阅读全文

posted @ 2024-03-14 13:37 神奇的萝卜丝 阅读(2) 评论(0) 推荐(0) 编辑

257. 二叉树的所有路径c
摘要:/** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */ /** * Note: The ret 阅读全文

posted @ 2024-03-14 13:32 神奇的萝卜丝 阅读(4) 评论(0) 推荐(0) 编辑

1137. 第 N 个泰波那契数c
摘要:int tribonacci(int n){ int* dp=(int*)malloc(sizeof(int)*(n+4)); dp[0]=0,dp[1]=1,dp[2]=1; for(int i=3;i<=n;i++) dp[i]=dp[i-1]+dp[i-2]+dp[i-3]; return d 阅读全文

posted @ 2024-03-13 23:57 神奇的萝卜丝 阅读(4) 评论(0) 推荐(0) 编辑

485. 最大连续 1 的个数c
摘要:int findMaxConsecutiveOnes(int* nums, int numsSize) { int max=0,sum=0,index=0; while(index<numsSize){ if(nums[index]==1){ sum++; if(sum>max) max=sum; 阅读全文

posted @ 2024-03-13 23:55 神奇的萝卜丝 阅读(3) 评论(0) 推荐(0) 编辑

LCR 128. 库存管理 Ic
摘要:这是很难得题目,标准解的二分查找,以后要掌握。 int stockManagement(int* stock, int stockSize) { int min=stock[0]; for(int i=1;i<stockSize;i++){ if(stock[i]<min) min=stock[i] 阅读全文

posted @ 2024-03-13 23:50 神奇的萝卜丝 阅读(6) 评论(0) 推荐(0) 编辑

278. 第一个错误的版本c
摘要:// The API isBadVersion is defined for you. // bool isBadVersion(int version); int firstBadVersion(int n) { int head=1,tail=n; if(isBadVersion(head)) 阅读全文

posted @ 2024-03-13 23:39 神奇的萝卜丝 阅读(3) 评论(0) 推荐(0) 编辑

面试题 17.12. BiNodec
摘要:树遍历的变形 /** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */ struct TreeN 阅读全文

posted @ 2024-03-13 23:25 神奇的萝卜丝 阅读(2) 评论(0) 推荐(0) 编辑

LCR 159. 库存管理 IIIc
摘要:经典快排 /** * Note: The returned array must be malloced, assume caller calls free(). */ int divide(int* a,int head,int tail){ int t=a[head]; while(head<t 阅读全文

posted @ 2024-03-13 23:07 神奇的萝卜丝 阅读(7) 评论(0) 推荐(0) 编辑

1089. 复写零c
摘要:void duplicateZeros(int* arr, int arrSize) { int* temp=(int*)malloc(sizeof(int)*arrSize); int head=0,index=0; while(head<arrSize && index<arrSize){ te 阅读全文

posted @ 2024-03-13 22:59 神奇的萝卜丝 阅读(3) 评论(0) 推荐(0) 编辑

88. 合并两个有序数组c
摘要:还有什么比刷简单题更爽的。 int cmp(const void* a,const void* b){ return *(int*)a-*(int*)b; } void merge(int* nums1, int nums1Size, int m, int* nums2, int nums2Size 阅读全文

posted @ 2024-03-13 22:53 神奇的萝卜丝 阅读(7) 评论(0) 推荐(0) 编辑

111. 二叉树的最小深度c
摘要:/** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */ int min(int i,int j 阅读全文

posted @ 2024-03-13 21:13 神奇的萝卜丝 阅读(3) 评论(0) 推荐(0) 编辑

559. N 叉树的最大深度c
摘要:/** * Definition for a Node. * struct Node { * int val; * int numChildren; * struct Node** children; * }; */ int maxDepth(struct Node* root) { if(!roo 阅读全文

posted @ 2024-03-13 21:08 神奇的萝卜丝 阅读(3) 评论(0) 推荐(0) 编辑

347. 前 K 个高频元素C
摘要:/** * Note: The returned array must be malloced, assume caller calls free(). */ typedef struct node{ int num; int count; }Hash; void inset(Hash* hash, 阅读全文

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

239. 滑动窗口最大值c
摘要:C语言没有优先队列库,如果自己实现的话在考试是不现实的。优先使用暴力简单的方法加稍微优化尽可能多的过例子。 /** * Note: The returned array must be malloced, assume caller calls free(). */ int findmax(int* 阅读全文

posted @ 2024-03-13 19:40 神奇的萝卜丝 阅读(2) 评论(0) 推荐(0) 编辑

150. 逆波兰表达式求值c
摘要:int cmp(int a,int b,char c){ if(c=='+') return a+b; if(c=='-') return a-b; if(c=='*') return a*b; return a/b; } int evalRPN(char** tokens, int tokensS 阅读全文

posted @ 2024-03-13 19:09 神奇的萝卜丝 阅读(4) 评论(0) 推荐(0) 编辑

28. 找出字符串中第一个匹配项的下标c
摘要:KMP! void buildnext(int* next,char* s){ int n=strlen(s); for(int i=0;i<n;i++){ next[i]=pre(s,i); printf("%d ",next[i]); } } int pre(char* s,int head){ 阅读全文

posted @ 2024-03-13 16:57 神奇的萝卜丝 阅读(4) 评论(0) 推荐(0) 编辑

142. 环形链表 IIc
摘要:/** * Definition for singly-linked list. * struct ListNode { * int val; * struct ListNode *next; * }; */ struct ListNode *detectCycle(struct ListNode 阅读全文

posted @ 2024-03-13 16:10 神奇的萝卜丝 阅读(2) 评论(0) 推荐(0) 编辑

76. 最小覆盖子串c
摘要:bool judge(int* temps,int* tempt){ for(int i=0;i<200;i++){ if(temps[i]<tempt[i]) return false; } return true; } char* minWindow(char* s, char* t) { in 阅读全文

posted @ 2024-03-13 15:24 神奇的萝卜丝 阅读(5) 评论(0) 推荐(0) 编辑

904. 水果成篮c
摘要:typedef struct node{ int fruit; int lastindex; }node; int totalFruit(int* fruits, int fruitsSize) { node f[2]; f[0].fruit=-1,f[1].fruit=-1; int max=0, 阅读全文

posted @ 2024-03-13 14:34 神奇的萝卜丝 阅读(2) 评论(0) 推荐(0) 编辑

209. 长度最小的子数组c
摘要:int minSubArrayLen(int target, int* nums, int numsSize) { int sum=nums[0],head=0,tail=0,min=INT_MAX; int t=0; for(int i=0;i<numsSize;i++){ t+=nums[i]; 阅读全文

posted @ 2024-03-13 14:12 神奇的萝卜丝 阅读(6) 评论(0) 推荐(0) 编辑

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 神奇的萝卜丝 阅读(2) 评论(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 神奇的萝卜丝 阅读(1) 评论(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 神奇的萝卜丝 阅读(1) 评论(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 神奇的萝卜丝 阅读(4) 评论(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 神奇的萝卜丝 阅读(3) 评论(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 神奇的萝卜丝 阅读(3) 评论(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 神奇的萝卜丝 阅读(3) 评论(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 神奇的萝卜丝 阅读(2) 评论(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) 编辑

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 神奇的萝卜丝 阅读(5) 评论(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 神奇的萝卜丝 阅读(11) 评论(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 神奇的萝卜丝 阅读(7) 评论(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 神奇的萝卜丝 阅读(1) 评论(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 神奇的萝卜丝 阅读(2) 评论(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 神奇的萝卜丝 阅读(2) 评论(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 神奇的萝卜丝 阅读(4) 评论(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 神奇的萝卜丝 阅读(2) 评论(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 神奇的萝卜丝 阅读(4) 评论(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 神奇的萝卜丝 阅读(5) 评论(0) 推荐(0) 编辑

1005. K 次取反后最大化的数组和c
摘要:int largestSumAfterKNegations(int* nums, int numsSize, int k) { int t[201]={0}; int sum=0; for(int i=0;i<numsSize;i++){ t[100+nums[i]]++; sum+=nums[i] 阅读全文

posted @ 2024-03-10 22:05 神奇的萝卜丝 阅读(5) 评论(0) 推荐(0) 编辑

45. 跳跃游戏 IIc
摘要:暴力DFS超时了。 先放着把。 int min; void dfs(int* nums,int numsSize,int index,int count){ if(index>=numsSize-1){ if(count <min) min=count; return ; } for(int i=n 阅读全文

posted @ 2024-03-10 21:34 神奇的萝卜丝 阅读(7) 评论(0) 推荐(0) 编辑

55. 跳跃游戏c
摘要:动态规划实在让人上瘾啊,虽然过程很难想,但是代码实现实在太简单了。 int max(int i,int j){ if(i>j ) return i; return j; } bool canJump(int* nums, int numsSize) { if(numsSize==1 && nums[ 阅读全文

posted @ 2024-03-10 20:38 神奇的萝卜丝 阅读(13) 评论(0) 推荐(0) 编辑

122. 买卖股票的最佳时机 II c
摘要:、 动态规划太难啦! int getmax(int i,int j){ if(i>j) return i; return j; } int maxProfit(int* prices, int pricesSize) { if(pricesSize==1) return 0; int** dp=(i 阅读全文

posted @ 2024-03-10 20:12 神奇的萝卜丝 阅读(2) 评论(0) 推荐(0) 编辑

53. 最大子数组和c
摘要:int max(int i,int j){ if(i>j) return i; return j; } int maxSubArray(int* nums, int numsSize) { if(numsSize==1) return nums[0]; int* dp=(int*)malloc(si 阅读全文

posted @ 2024-03-10 19:28 神奇的萝卜丝 阅读(3) 评论(0) 推荐(0) 编辑

376. 摆动序列c
摘要:动态规划yyds!虽然写不出来TT int max(int i,int j){ if(i>j) return i; return j; } int wiggleMaxLength(int* nums, int numsSize){ int dp[1000][2]={0};//dp[i][j] 表示到 阅读全文

posted @ 2024-03-10 17:14 神奇的萝卜丝 阅读(5) 评论(0) 推荐(0) 编辑

455. 分发饼干c
摘要:int cmp(const void* a,const void* b){ return *(int*)a-*(int*)b; } int findContentChildren(int* g, int gSize, int* s, int sSize) { qsort(g,gSize,sizeof 阅读全文

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

51. N 皇后c
摘要:\ 这题就是第一次做的时候,斜线没考虑清楚,有四个方向斜线。 /** * Return an array of arrays of size *returnSize. * The sizes of the arrays are returned as *returnColumnSizes array 阅读全文

posted @ 2024-03-10 14:00 神奇的萝卜丝 阅读(2) 评论(0) 推荐(0) 编辑

47. 全排列 IIc
摘要:我宣布我已经参透了套路,一次AC /** * Return an array of arrays of size *returnSize. * The sizes of the arrays are returned as *returnColumnSizes array. * Note: Both 阅读全文

posted @ 2024-03-09 21:25 神奇的萝卜丝 阅读(7) 评论(0) 推荐(0) 编辑

46. 全排列c
摘要:出息了!一次AC /** * Return an array of arrays of size *returnSize. * The sizes of the arrays are returned as *returnColumnSizes array. * Note: Both returne 阅读全文

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

491. 非递减子序列c
摘要:复试的人真的搞心态啊,怎么能这么变态,刷题这么块。哭了。 要是难一点的重复问题还是写for循环好点。 /** * Return an array of arrays of size *returnSize. * The sizes of the arrays are returned as *ret 阅读全文

posted @ 2024-03-09 21:02 神奇的萝卜丝 阅读(5) 评论(0) 推荐(0) 编辑

90. 子集 IIc
摘要:非常好的题目,使我的大脑飞速旋转!! UP主代码随想录 结果: 阅读全文

posted @ 2024-03-09 17:56 神奇的萝卜丝 阅读(3) 评论(0) 推荐(0) 编辑

78. 子集c
摘要:leetcode官方解法实在是太绝了!!二刷的时候一定用上! /** * Return an array of arrays of size *returnSize. * The sizes of the arrays are returned as *returnColumnSizes array 阅读全文

posted @ 2024-03-09 15:56 神奇的萝卜丝 阅读(5) 评论(0) 推荐(0) 编辑

93. 复原 IP 地址c
摘要:、 leetcode调试功能真香啊,效率高了不少。但钱包也变扁了。。 /** * Note: The returned array must be malloced, assume caller calls free(). */ char temp[30]; int top=0; bool judg 阅读全文

posted @ 2024-03-09 15:24 神奇的萝卜丝 阅读(6) 评论(0) 推荐(0) 编辑

131. 分割回文串c
摘要:这题真的坑爹啊,不明白为什么会产生万大小的数据啊。 /** * Return an array of arrays of size *returnSize. * The sizes of the arrays are returned as *returnColumnSizes array. * N 阅读全文

posted @ 2024-03-09 14:35 神奇的萝卜丝 阅读(6) 评论(0) 推荐(0) 编辑

40. 组合总和 IIc
摘要:很好的题目,使我的大脑旋转。 /** * Return an array of arrays of size *returnSize. * The sizes of the arrays are returned as *returnColumnSizes array. * Note: Both r 阅读全文

posted @ 2024-03-08 18:24 神奇的萝卜丝 阅读(1) 评论(0) 推荐(0) 编辑

39. 组合总和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-08 17:38 神奇的萝卜丝 阅读(3) 评论(0) 推荐(0) 编辑

17. 电话号码的字母组合c
摘要:C语言字符串细节真多啊,搞了好久。 /** * Note: The returned array must be malloced, assume caller calls free(). */ char c[10][5]={" "," ","abc","def","ghi","jkl","mno" 阅读全文

posted @ 2024-03-08 15:55 神奇的萝卜丝 阅读(9) 评论(0) 推荐(0) 编辑

216. 组合总和 IIIc
摘要:/** * 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-07 20:48 神奇的萝卜丝 阅读(1) 评论(0) 推荐(0) 编辑

77. 组合C
摘要:回溯其实就是抽象图的遍历过程 这题数据实在太离谱了。 /** * Return an array of arrays of size *returnSize. * The sizes of the arrays are returned as *returnColumnSizes array. * 阅读全文

posted @ 2024-03-07 19:52 神奇的萝卜丝 阅读(2) 评论(0) 推荐(0) 编辑

538. 把二叉搜索树转换为累加树c
摘要:右根左遍历就行。 /** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */ void order 阅读全文

posted @ 2024-03-07 15:36 神奇的萝卜丝 阅读(2) 评论(0) 推荐(0) 编辑

108. 将有序数组转换为二叉搜索树c
摘要:如果按一般思路建一个平衡二叉树,非常麻烦。 但是二分查找树就一个平衡二叉树,所有构建二叉查找树就行。 /** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * 阅读全文

posted @ 2024-03-07 15:09 神奇的萝卜丝 阅读(10) 评论(0) 推荐(0) 编辑

669. 修剪二叉搜索树c
摘要:这题还是很难得。一看是想着当作普通二叉树所有节点都递归,但是很难做,难度很高。 /** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct Tree 阅读全文

posted @ 2024-03-07 14:43 神奇的萝卜丝 阅读(3) 评论(0) 推荐(0) 编辑

450. 删除二叉搜索树中的节点c
摘要:这题特别好,和递归删除链表里的元素有异曲同工之妙 /** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * 阅读全文

posted @ 2024-03-07 13:22 神奇的萝卜丝 阅读(1) 评论(0) 推荐(0) 编辑

701. 二叉搜索树中的插入操作c
摘要:/** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */ struct TreeNode* in 阅读全文

posted @ 2024-03-06 20:28 神奇的萝卜丝 阅读(2) 评论(0) 推荐(0) 编辑

235. 二叉搜索树的最近公共祖先c
摘要:/** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */ struct TreeNode* pr 阅读全文

posted @ 2024-03-06 20:02 神奇的萝卜丝 阅读(4) 评论(0) 推荐(0) 编辑

236. 二叉树的最近公共祖先c
摘要:思想就是层次遍历,然后判断每个节点是否为父节点、 /** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * 阅读全文

posted @ 2024-03-06 19:31 神奇的萝卜丝 阅读(2) 评论(0) 推荐(0) 编辑

530. 二叉搜索树的最小绝对差c
摘要:/** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */ void inorder(struct 阅读全文

posted @ 2024-03-06 15:02 神奇的萝卜丝 阅读(3) 评论(0) 推荐(0) 编辑

98. 验证二叉搜索树c
摘要:/** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */ bool judge(struct T 阅读全文

posted @ 2024-03-06 13:59 神奇的萝卜丝 阅读(4) 评论(0) 推荐(0) 编辑

700. 二叉搜索树中的搜索c
摘要:/** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */ struct TreeNode* se 阅读全文

posted @ 2024-03-06 13:33 神奇的萝卜丝 阅读(18) 评论(0) 推荐(0) 编辑

617. 合并二叉树 c
摘要:/** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */ struct TreeNode* me 阅读全文

posted @ 2024-03-06 13:28 神奇的萝卜丝 阅读(3) 评论(0) 推荐(0) 编辑

654. 最大二叉树c
摘要:/** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */ int maxindex(int* n 阅读全文

posted @ 2024-03-06 13:19 神奇的萝卜丝 阅读(3) 评论(0) 推荐(0) 编辑

106. 从中序与后序遍历序列构造二叉树 c
摘要:/** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */ struct TreeNode* bu 阅读全文

posted @ 2024-03-06 13:09 神奇的萝卜丝 阅读(3) 评论(0) 推荐(0) 编辑

112. 路径总和c
摘要:/** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */ bool judge(struct T 阅读全文

posted @ 2024-03-05 22:18 神奇的萝卜丝 阅读(3) 评论(0) 推荐(0) 编辑

513. 找树左下角的值c
摘要:用的层序遍历 /** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */ int findBott 阅读全文

posted @ 2024-03-05 22:01 神奇的萝卜丝 阅读(2) 评论(0) 推荐(0) 编辑

404. 左叶子之和c
摘要:/** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */ void postorder(stru 阅读全文

posted @ 2024-03-05 21:38 神奇的萝卜丝 阅读(2) 评论(0) 推荐(0) 编辑

257. 二叉树的所有路径c
摘要:很好的题目,让我的sprintf旋转 /** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */ 阅读全文

posted @ 2024-03-05 20:34 神奇的萝卜丝 阅读(3) 评论(0) 推荐(0) 编辑

110. 平衡二叉树c
摘要:/** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */ int max(int i,int j 阅读全文

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

222. 完全二叉树的节点个数c
摘要:/** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */ int countNodes(stru 阅读全文

posted @ 2024-03-05 16:40 神奇的萝卜丝 阅读(5) 评论(0) 推荐(0) 编辑

111. 二叉树的最小深度c
摘要:/** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */ int min(int i,int j 阅读全文

posted @ 2024-03-05 16:37 神奇的萝卜丝 阅读(2) 评论(0) 推荐(0) 编辑

559. N 叉树的最大深度c
摘要:/** * Definition for a Node. * struct Node { * int val; * int numChildren; * struct Node** children; * }; */ int maxDepth(struct Node* root) { if(!roo 阅读全文

posted @ 2024-03-05 16:29 神奇的萝卜丝 阅读(2) 评论(0) 推荐(0) 编辑

104. 二叉树的最大深度c
摘要:/** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */ int max(int i,int j 阅读全文

posted @ 2024-03-05 15:59 神奇的萝卜丝 阅读(7) 评论(0) 推荐(0) 编辑

572. 另一棵树的子树c
摘要:/** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */ bool issameroot(str 阅读全文

posted @ 2024-03-05 15:53 神奇的萝卜丝 阅读(2) 评论(0) 推荐(0) 编辑

100. 相同的树c
摘要:/** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */ bool isSameTree(str 阅读全文

posted @ 2024-03-05 15:35 神奇的萝卜丝 阅读(2) 评论(0) 推荐(0) 编辑

101. 对称二叉树c
摘要:/** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */ bool judge(struct T 阅读全文

posted @ 2024-03-05 15:31 神奇的萝卜丝 阅读(2) 评论(0) 推荐(0) 编辑

226. 翻转二叉树 c
摘要:层次遍历的题目C写吐血了,缓一缓再写那种气死人的题目。 /** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; 阅读全文

posted @ 2024-03-05 15:08 神奇的萝卜丝 阅读(3) 评论(0) 推荐(0) 编辑

KY148 还是畅通工程c
摘要:这题好像更新了呀,不压缩路径的话,find函数用递归的话会栈溢出。 #include <stdio.h> #include<stdbool.h> #include<stdlib.h> int set[101]; typedef struct node{ int length; int e1; int 阅读全文

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

Square c
摘要:要去寻找所有可能性,典型的dfs问题 #include<stdio.h> #include<stdlib.h> #include<stdbool.h> bool judge(int* temp,int* visit,int noweedge,int length,int n,int nowlengt 阅读全文

posted @ 2024-03-03 16:21 神奇的萝卜丝 阅读(5) 评论(0) 推荐(0) 编辑

4147:汉诺塔问题(Tower of Hanoi)
摘要:#include<stdio.h> void move(int tail,char now,char tool,char end,int n){//以nown为低,共 n个 if(n <=0) return; move(tail-1,now,end,tool,n-1); printf("%d:%c- 阅读全文

posted @ 2024-03-02 19:53 神奇的萝卜丝 阅读(15) 评论(0) 推荐(0) 编辑

541. 反转字符串 II
摘要:void reversestring(char* s,int head,int tail){ while(head<=tail){ char temp=s[head]; s[head]=s[tail]; s[tail]=temp; head++; tail--; } } char* reverseS 阅读全文

posted @ 2024-03-01 15:24 神奇的萝卜丝 阅读(2) 评论(0) 推荐(0) 编辑

454. 四数相加 II c
摘要:typedef struct node{ int sum; int count; struct node* repeatnext; }hash; void init_hash(hash* h){ for(int i=0;i<128;i++){ h[i].sum=0; h[i].count=0; h[ 阅读全文

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

151. 反转字符串中的单词 c
摘要:void reversestring(char* s,int head,int tail){ while(head<=tail){ char temp=s[head]; s[head]=s[tail]; s[tail]=temp; head++; tail--; } } char* reverseW 阅读全文

posted @ 2024-03-01 14:23 神奇的萝卜丝 阅读(3) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示