上一页 1 ··· 29 30 31 32 33 34 35 36 37 ··· 63 下一页
摘要: int findKthPositive(int* arr, int arrSize, int k){ int i=1,pst=0; while(i<=1000 && pst<arrSize) { (i++ != arr[pst])? k--: pst++; if (!k) return i-1; } 阅读全文
posted @ 2020-09-23 18:05 温暖了寂寞 阅读(206) 评论(0) 推荐(0) 编辑
摘要: /*递归*/ int recursion(struct ListNode* head, int k, int* num){ if (!head) { (*num)=1; return 100000; } int ret = recursion(head->next, k, num); if (ret 阅读全文
posted @ 2020-09-23 17:30 温暖了寂寞 阅读(126) 评论(0) 推荐(0) 编辑
摘要: int dominantIndex(int* nums, int numsSize){ int i,max=0,maxsec=0,maxi=0; for(i=0;i<numsSize;i++) { if(nums[i]>max)//优先满足第一大元素的判断 { maxsec=max; maxi=i; 阅读全文
posted @ 2020-09-23 16:31 温暖了寂寞 阅读(123) 评论(0) 推荐(0) 编辑
摘要: int cmp(const void* a, const void* b){ return *(int*)b - *(int*)a; } int largestPerimeter(int* A, int ASize){ qsort(A,ASize,sizeof(int),cmp); for (int 阅读全文
posted @ 2020-09-23 16:21 温暖了寂寞 阅读(170) 评论(0) 推荐(0) 编辑
摘要: /*遍历所有3个店组合可能,求3边,海伦公式求面积 sqrt((a+b+c)*(a+b-c)*(a+c-b)*(b+c-a))/4 */ double largestTriangleArea(int** points, int pointsSize, int* pointsColSize){ dou 阅读全文
posted @ 2020-09-23 16:04 温暖了寂寞 阅读(196) 评论(0) 推荐(0) 编辑
摘要: int cmp(const void* a, const void* b){ return *(int*)b - *(int*)a; } int lastStoneWeight(int* stones, int stonesSize){ int i=0,val=stones[0]; while(i< 阅读全文
posted @ 2020-09-23 12:39 温暖了寂寞 阅读(155) 评论(0) 推荐(0) 编辑
摘要: bool recursion(struct TreeNode* root, int* arr, int* pst) { if (!root->left && !root->right) { if (!arr[*pst]) { arr[(*pst)++] = root->val; return tru 阅读全文
posted @ 2020-09-23 10:58 温暖了寂寞 阅读(153) 评论(0) 推荐(0) 编辑
摘要: bool lemonadeChange(int* bills, int billsSize){ int hash[11] = {0},i; for (i=0; i<billsSize; i++) { if (bills[i] == 5) hash[5]++; else if (bills[i] == 阅读全文
posted @ 2020-09-23 10:06 温暖了寂寞 阅读(112) 评论(0) 推荐(0) 编辑
摘要: int lengthOfLastWord(char * s){ int i,len=strlen(s),count=0; for (i=len-1; i>=0; i--) { if (s[i] != ' ') count++; else if (count>0 && s[i] == ' ') bre 阅读全文
posted @ 2020-09-23 09:36 温暖了寂寞 阅读(87) 评论(0) 推荐(0) 编辑
摘要: char * licenseKeyFormatting(char * S, int K){ int i,j=0,count=0,pst=0,n=0; int len = strlen(S); char* str = (char*)calloc(len*2,sizeof(char)); char* r 阅读全文
posted @ 2020-09-23 09:19 温暖了寂寞 阅读(195) 评论(0) 推荐(0) 编辑
上一页 1 ··· 29 30 31 32 33 34 35 36 37 ··· 63 下一页