llllmz

导航

2024年3月15日

面试题 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 神奇的萝卜丝 阅读(14) 评论(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 神奇的萝卜丝 阅读(10) 评论(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 神奇的萝卜丝 阅读(25) 评论(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 神奇的萝卜丝 阅读(20) 评论(0) 推荐(0)

2235. 两整数相加

摘要: int sum(int num1, int num2){ return num1+num2; } 阅读全文

posted @ 2024-03-15 21:45 神奇的萝卜丝 阅读(12) 评论(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 神奇的萝卜丝 阅读(12) 评论(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 神奇的萝卜丝 阅读(16) 评论(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 神奇的萝卜丝 阅读(14) 评论(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 神奇的萝卜丝 阅读(19) 评论(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 神奇的萝卜丝 阅读(6) 评论(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 神奇的萝卜丝 阅读(11) 评论(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 神奇的萝卜丝 阅读(20) 评论(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 神奇的萝卜丝 阅读(14) 评论(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 神奇的萝卜丝 阅读(22) 评论(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 神奇的萝卜丝 阅读(20) 评论(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 神奇的萝卜丝 阅读(8) 评论(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 神奇的萝卜丝 阅读(38) 评论(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 神奇的萝卜丝 阅读(13) 评论(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 神奇的萝卜丝 阅读(11) 评论(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 神奇的萝卜丝 阅读(14) 评论(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 神奇的萝卜丝 阅读(33) 评论(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 神奇的萝卜丝 阅读(16) 评论(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 神奇的萝卜丝 阅读(20) 评论(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 神奇的萝卜丝 阅读(19) 评论(0) 推荐(0)