上一页 1 ··· 16 17 18 19 20 21 22 23 24 ··· 63 下一页
摘要: /** * Note: The returned array must be malloced, assume caller calls free(). */ int* constructRectangle(int area, int* returnSize){ int* arr = (int*)c 阅读全文
posted @ 2020-11-26 20:19 温暖了寂寞 阅读(49) 评论(0) 推荐(0) 编辑
摘要: //结构体存放数组元素的下标和值,接着快排,最后再逐个比较 typedef struct { int index; int val; }st; int cmp(const void* a, const void* b){ return ((*(st*)a).val != (*(st*)b).val) 阅读全文
posted @ 2020-11-26 16:57 温暖了寂寞 阅读(87) 评论(0) 推荐(0) 编辑
摘要: int countLargestGroup(int n){ int hash[37]={0}; int map[10001]={0}; int i, sum, tmp, max=0, cnt=0; for(i=1; i<=n; i++){ map[i]=map[i/10]+i%10; hash[ma 阅读全文
posted @ 2020-11-26 12:41 温暖了寂寞 阅读(119) 评论(0) 推荐(0) 编辑
摘要: int maxSubArray(int* nums, int numsSize){ int max=nums[0], sum=0, i; for(i=0; i<numsSize; i++){ sum+=nums[i]; if(sum>max) max=sum; if(sum<0) sum=0; } 阅读全文
posted @ 2020-11-25 20:44 温暖了寂寞 阅读(74) 评论(0) 推荐(0) 编辑
摘要: int getDecimalValue(struct ListNode* head){ int ans=0; struct ListNode* cur=head; while(cur){ ans=ans*2+cur->val; cur=cur->next; } return ans; } 阅读全文
posted @ 2020-11-25 18:18 温暖了寂寞 阅读(64) 评论(0) 推荐(0) 编辑
摘要: int convertInteger(int A, int B){ A^=B; int ret=0; for(int i=0;i<32;i++){ if((A>>i)&1==1){ ret++; } } return ret; } 阅读全文
posted @ 2020-11-25 18:10 温暖了寂寞 阅读(75) 评论(0) 推荐(0) 编辑
摘要: int* getNoZeroIntegers(int n, int* returnSize){ int unit, i, num=0, cnt=0, temp=n; int* arr=(int*)calloc(2,sizeof(int)); while(n>0){ unit=n%10; for(i= 阅读全文
posted @ 2020-11-25 17:49 温暖了寂寞 阅读(102) 评论(0) 推荐(0) 编辑
摘要: struct TreeNode* sortedArrayToBST(int* nums, int numsSize){ struct TreeNode* p_node=(struct TreeNode*)malloc(sizeof(struct TreeNode)); if(0==numsSize 阅读全文
posted @ 2020-11-25 14:42 温暖了寂寞 阅读(63) 评论(0) 推荐(0) 编辑
摘要: char * toHex(int num){ if (num==0) return "0"; char* retStr = (char*)calloc(sizeof(char),10); memset(retStr,'0',sizeof(char)*8); char mapping[] = {'0' 阅读全文
posted @ 2020-11-25 12:19 温暖了寂寞 阅读(92) 评论(0) 推荐(0) 编辑
摘要: #define min(a,b) (a<b)?(a) :(b) int countBinarySubstrings(char * s){ int i, j, cnt = 0, len = strlen(s), sum=0, preVal=0, ret; for (i = 0; i < len; i+ 阅读全文
posted @ 2020-11-24 20:11 温暖了寂寞 阅读(58) 评论(0) 推荐(0) 编辑
上一页 1 ··· 16 17 18 19 20 21 22 23 24 ··· 63 下一页