摘要: struct TreeNode* lowestCommonAncestor(struct TreeNode* root, struct TreeNode* p, struct TreeNode* q) { if(root == NULL){ return NULL; } if(q->val > ro 阅读全文
posted @ 2020-09-21 17:30 温暖了寂寞 阅读(131) 评论(0) 推荐(0) 编辑
摘要: int* luckyNumbers (int** matrix, int matrixSize, int* matrixColSize, int* returnSize){ int i,j,k,count=0,min,col,pst=0; int* retArr = (int*)malloc(siz 阅读全文
posted @ 2020-09-21 16:24 温暖了寂寞 阅读(188) 评论(0) 推荐(0) 编辑
摘要: int findMagicIndex(int* nums, int numsSize){ for (int i=0; i<numsSize; i++) { if (i == nums[i]) return i; } return -1; } 阅读全文
posted @ 2020-09-21 14:13 温暖了寂寞 阅读(118) 评论(0) 推荐(0) 编辑
摘要: int majorityElement(int* nums, int numsSize){ int key = nums[0]; int count = 0; for (size_t i = 0; i < numsSize; i++) { if(nums[i] == key) count++; el 阅读全文
posted @ 2020-09-21 13:10 温暖了寂寞 阅读(79) 评论(0) 推荐(0) 编辑
摘要: char * makeGood(char * s){ int pst=0,i,len=strlen(s); for (i=1; i<len; i++) { if (pst>=0 && abs(s[pst]-s[i]) == 32) pst--; else s[++pst] = s[i]; } s[p 阅读全文
posted @ 2020-09-21 11:37 温暖了寂寞 阅读(92) 评论(0) 推荐(0) 编辑
摘要: bool canBeEqual(int* target, int targetSize, int* arr, int arrSize){ int i,val=0,sum=0; for (i=0; i<targetSize; i++) { sum += target[i] - arr[i]; val 阅读全文
posted @ 2020-09-21 10:21 温暖了寂寞 阅读(116) 评论(0) 推荐(0) 编辑
摘要: int* masterMind(char* solution, char* guess, int* returnSize){ int* arr = (int*)calloc(2,sizeof(int)); int s_hash[26] = {0}; int g_hash[26] = {0}; int 阅读全文
posted @ 2020-09-21 09:56 温暖了寂寞 阅读(228) 评论(0) 推荐(0) 编辑
摘要: int cmp(const void* a, const void* b){ return (abs((*(int**)a)[0]) + abs((*(int**)a)[1])) - (abs((*(int**)b)[0]) + abs((*(int**)b)[1])); } int** allCe 阅读全文
posted @ 2020-09-21 09:29 温暖了寂寞 阅读(164) 评论(0) 推荐(0) 编辑