摘要: 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) 编辑