上一页 1 ··· 31 32 33 34 35 36 37 38 39 ··· 63 下一页
摘要: 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) 编辑
摘要: int diagonalSum(int** mat, int matSize, int* matColSize){ int row=0,col1=0,col2=(*matColSize)-1,sum=0; while(row<matSize && col1<*matColSize && col2>= 阅读全文
posted @ 2020-09-20 12:44 温暖了寂寞 阅读(190) 评论(0) 推荐(0) 编辑
摘要: int findMaxConsecutiveOnes(int* nums, int numsSize){ int max=0,sum=0,i; for (i=0; i<numsSize; i++) { if (nums[i]) { sum++; if (i == numsSize-1 || nums 阅读全文
posted @ 2020-09-20 11:59 温暖了寂寞 阅读(146) 评论(0) 推荐(0) 编辑
摘要: int cmp(const void* a, const void* b){ return abs(*(int*)b) - abs(*(int*)a); } int largestSumAfterKNegations(int* A, int ASize, int K){ int i,sum=0; q 阅读全文
posted @ 2020-09-20 11:38 温暖了寂寞 阅读(118) 评论(0) 推荐(0) 编辑
摘要: #include <Math.h> int maximum69Number (int num){ int count = 0, th = 0; // count 记录除了多少次,th记录最大的6在第几位 int re = num; while(re){ count++; if(re%10==6) t 阅读全文
posted @ 2020-09-20 10:57 温暖了寂寞 阅读(170) 评论(0) 推荐(0) 编辑
上一页 1 ··· 31 32 33 34 35 36 37 38 39 ··· 63 下一页