llllmz

导航

上一页 1 2 3 4 5 6 7 8 ··· 30 下一页

2024年3月20日

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

2024年3月19日

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

上一页 1 2 3 4 5 6 7 8 ··· 30 下一页