摘要: struct ListNode *getIntersectionNode(struct ListNode *headA, struct ListNode *headB) { if(!headA || !headB) return NULL; struct ListNode *pa = headA; 阅读全文
posted @ 2020-09-24 23:29 温暖了寂寞 阅读(79) 评论(0) 推荐(0) 编辑
摘要: struct TreeNode* invertTree(struct TreeNode* root){ if(!root) return NULL; struct TreeNode* node =root->left; root->left=invertTree(root->right); root 阅读全文
posted @ 2020-09-24 20:19 温暖了寂寞 阅读(99) 评论(0) 推荐(0) 编辑
摘要: //递归 bool isSubsequence(char * s, char * t){ /* 写法 1: */ return (*s =='\0'? true:*t=='\0'?false:(*s)!=(*t)?isSubsequence(s,t+1):isSubsequence(s+1,t+1) 阅读全文
posted @ 2020-09-24 18:04 温暖了寂寞 阅读(117) 评论(0) 推荐(0) 编辑
摘要: bool isUnique(char* astr){ int hash[128]={0}; for (int i=0; i<strlen(astr); i++) { if (hash[astr[i]]) return false; else hash[astr[i]]++; } return tru 阅读全文
posted @ 2020-09-24 17:30 温暖了寂寞 阅读(129) 评论(0) 推荐(0) 编辑
摘要: //没有额外单独格子干扰情况int islandPerimeter(int **grid, int gridSize, int* gridColSize) { int len = 0; for (int i = 0; i < gridSize; i++) { for (int j = 0; j < 阅读全文
posted @ 2020-09-24 16:20 温暖了寂寞 阅读(160) 评论(0) 推荐(0) 编辑
摘要: /*双哈希 其实就是a对应b 同时b对应a 保证唯一 */ bool isIsomorphic(char * s, char * t){ int hash1[128]={0},hash2[128]={0},i; for (i=0; s[i] != '\0'; i++) { if (hash1[s[i 阅读全文
posted @ 2020-09-24 15:20 温暖了寂寞 阅读(144) 评论(0) 推荐(0) 编辑
摘要: int numJewelsInStones(char * J, char * S){ int i,num=0; for(i=0;S[i]!='\0';i++){ if(strchr(J,S[i])) //若S[i]在J中则返回一个S[i]所在位置的指针 num++; } return num; } 阅读全文
posted @ 2020-09-24 14:48 温暖了寂寞 阅读(128) 评论(0) 推荐(0) 编辑
摘要: int cmp(const void* a,const void* b){ return *(int*)a - *(int*)b; } int findPairs(int* nums, int numsSize, int k){ if(numsSize<2)return 0; qsort(nums, 阅读全文
posted @ 2020-09-24 14:29 温暖了寂寞 阅读(141) 评论(0) 推荐(0) 编辑
摘要: char ** findWords(char ** words, int wordsSize, int* returnSize){ char* symbol[] = {"123456789","qwertyuiop","asdfghjkl","zxcvbnm"}; char** arr = (cha 阅读全文
posted @ 2020-09-24 11:39 温暖了寂寞 阅读(164) 评论(0) 推荐(0) 编辑
摘要: bool* kidsWithCandies(int* candies, int candiesSize, int extraCandies, int* returnSize){ int max=0,i; bool* arr = (bool*)malloc(candiesSize); for (i=0 阅读全文
posted @ 2020-09-24 10:43 温暖了寂寞 阅读(102) 评论(0) 推荐(0) 编辑
摘要: typedef struct { int k; int* nums; } KthLargest; int cmp(const void* a, const void* b){ return *(int*)b - *(int*)a; } KthLargest* kthLargestCreate(int 阅读全文
posted @ 2020-09-24 01:13 温暖了寂寞 阅读(189) 评论(0) 推荐(0) 编辑