摘要: 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) 编辑
摘要: double findMaxAverage(int* nums, int numsSize, int k){ double max=0,sum; int i; for (i=0; i<k; i++) max += nums[i]; sum = max; for (i=k; i<numsSize; i 阅读全文
posted @ 2020-09-20 10:24 温暖了寂寞 阅读(144) 评论(0) 推荐(0) 编辑
摘要: int maxDepth(struct TreeNode* root){ if (!root) return 0; int left = maxDepth(root->left); int right = maxDepth(root->right); return (left > right)? l 阅读全文
posted @ 2020-09-20 09:28 温暖了寂寞 阅读(97) 评论(0) 推荐(0) 编辑
摘要: int maxDepth(struct Node* root){ if(!root) return 0; int max = 0; for(int i = 0; i < root->numChildren; ++i){ int temp = maxDepth(root->children[i]); 阅读全文
posted @ 2020-09-20 08:54 温暖了寂寞 阅读(163) 评论(0) 推荐(0) 编辑
摘要: int maximum(int a, int b){ return (int)((fabs((long)b - (long)a) + a + b) / 2); } 阅读全文
posted @ 2020-09-20 08:14 温暖了寂寞 阅读(228) 评论(0) 推荐(0) 编辑
摘要: int maxNumberOfBalloons(char * text){ int i=0,len=strlen(text),hash[50]={0},min=10000; char* s = "balon"; for(; i<len; i++) hash[text[i]-'a']++; for ( 阅读全文
posted @ 2020-09-20 07:56 温暖了寂寞 阅读(160) 评论(0) 推荐(0) 编辑
摘要: /*快排后 取最小两个负数和最大正数乘积和最大三个正数乘积比较取较大值*/ int cmp(const void* a, const void* b){ return *(int*)a - *(int*)b; } int maximumProduct(int* nums, int numsSize) 阅读全文
posted @ 2020-09-20 07:33 温暖了寂寞 阅读(219) 评论(0) 推荐(0) 编辑