llllmz

导航

上一页 1 ··· 22 23 24 25 26 27 28 29 30 ··· 35 下一页

2024年2月28日

350. 两个数组的交集 II C

摘要: /** * Note: The returned array must be malloced, assume caller calls free(). */ int min(int i,int j){ if(i<j) return i; return j; } int* intersect(int 阅读全文

posted @ 2024-02-28 20:24 神奇的萝卜丝 阅读(11) 评论(0) 推荐(0)

349. 两个数组的交集C

摘要: /** * Note: The returned array must be malloced, assume caller calls free(). */ int* intersection(int* nums1, int nums1Size, int* nums2, int nums2Size 阅读全文

posted @ 2024-02-28 20:07 神奇的萝卜丝 阅读(13) 评论(0) 推荐(0)

383. 赎金信C

摘要: \ int hash(char c){ return c-'a'; } bool canConstruct(char* ransomNote, char* magazine) { if(!ransomNote) return true; if(!magazine) return false; int 阅读全文

posted @ 2024-02-28 19:58 神奇的萝卜丝 阅读(22) 评论(0) 推荐(0)

242. 有效的字母异位词 C

摘要: int hash(char c){ return c-'a'; } bool isAnagram(char* s, char* t) { int a[26]={0}; int b[26]={0}; int i=0; while(s[i]!=0){ a[hash(s[i++])]++; } i=0; 阅读全文

posted @ 2024-02-28 17:54 神奇的萝卜丝 阅读(5) 评论(0) 推荐(0)

142. 环形链表 II C

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

posted @ 2024-02-28 17:47 神奇的萝卜丝 阅读(5) 评论(0) 推荐(0)

面试题 02.07. 链表相交C

摘要: 利用链表的特性,如果相交的话,后面就不可能岔开! 你可以想象把他们有同一个尾巴,然后从尾巴往前看。 所以只要知道两个链表的长度,就可以在同一起跑线上一起比较了。 /** * Definition for singly-linked list. * struct ListNode { * int va 阅读全文

posted @ 2024-02-28 16:47 神奇的萝卜丝 阅读(7) 评论(0) 推荐(0)

19. 删除链表的倒数第 N 个结点C

摘要: /** * Definition for singly-linked list. * struct ListNode { * int val; * struct ListNode *next; * }; */ struct ListNode* removeNthFromEnd(struct List 阅读全文

posted @ 2024-02-28 16:30 神奇的萝卜丝 阅读(10) 评论(0) 推荐(0)

24. 两两交换链表中的节点C

摘要: 没必要纠结太麻烦的方法。 简单的就两种,一个就是新拿出来空间来装。 要不然就是直接前后数据换一下就行了。 然后需要考虑表空的情况。 结果: /** * Definition for singly-linked list. * struct ListNode { * int val; * struct 阅读全文

posted @ 2024-02-28 16:13 神奇的萝卜丝 阅读(7) 评论(0) 推荐(0)

206. 反转链表C

摘要: /** * Definition for singly-linked list. * struct ListNode { * int val; * struct ListNode *next; * }; */ struct ListNode* reverseList(struct ListNode* 阅读全文

posted @ 2024-02-28 15:58 神奇的萝卜丝 阅读(11) 评论(0) 推荐(0)

203. 移除链表元素C

摘要: 写了个递归 /** * Definition for singly-linked list. * struct ListNode { * int val; * struct ListNode *next; * }; */ struct ListNode* delect(struct ListNode 阅读全文

posted @ 2024-02-28 13:39 神奇的萝卜丝 阅读(4) 评论(0) 推荐(0)

上一页 1 ··· 22 23 24 25 26 27 28 29 30 ··· 35 下一页