llllmz

导航

2024年3月20日

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 神奇的萝卜丝 阅读(10) 评论(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 神奇的萝卜丝 阅读(10) 评论(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 神奇的萝卜丝 阅读(7) 评论(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 神奇的萝卜丝 阅读(17) 评论(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 神奇的萝卜丝 阅读(7) 评论(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 神奇的萝卜丝 阅读(7) 评论(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 神奇的萝卜丝 阅读(8) 评论(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 神奇的萝卜丝 阅读(8) 评论(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 神奇的萝卜丝 阅读(21) 评论(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 神奇的萝卜丝 阅读(8) 评论(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 神奇的萝卜丝 阅读(9) 评论(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 神奇的萝卜丝 阅读(9) 评论(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 神奇的萝卜丝 阅读(12) 评论(0) 推荐(0)