上一页 1 ··· 13 14 15 16 17 18 19 20 21 ··· 63 下一页
摘要: char * convertToBase7(int num){ if (num==0) return "0"; char* s = (char*)calloc(1001,sizeof(char)); int pst=1000, flag=(num<0)?1 :0; num = abs(num); c 阅读全文
posted @ 2020-12-01 12:10 温暖了寂寞 阅读(83) 评论(0) 推荐(0) 编辑
摘要: int calPoints(char ** ops, int opsSize){ int arr[1000]={0}, i, pst=0, temp, sum=0; for(i=0; i<opsSize; i++){ if(isdigit(ops[i][0]) || ops[i][0] == '-' 阅读全文
posted @ 2020-12-01 11:36 温暖了寂寞 阅读(86) 评论(0) 推荐(0) 编辑
摘要: int maxProfit(int* prices, int pricesSize){ int sum=0, i, max=0; for(i=1; i<pricesSize; i++){ sum += prices[i]-prices[i-1]; if(sum<0) sum=0; if(sum>ma 阅读全文
posted @ 2020-12-01 11:00 温暖了寂寞 阅读(63) 评论(0) 推荐(0) 编辑
摘要: int maxProfit(int* prices, int pricesSize){ int ans = 0; for (int i = 1; i < pricesSize; ++i) { /* 当天价格大于前一天价格,前一天买入,当天卖出,利润累加 */ ans += fmax(0, price 阅读全文
posted @ 2020-12-01 09:45 温暖了寂寞 阅读(55) 评论(0) 推荐(0) 编辑
摘要: int binaryGap(int n){ int max=0, pre=-1, cnt=0; while(n){ if((n&1) == 1 ){ if(pre>=0 && cnt-pre > max) max=cnt-pre; pre=cnt; } cnt++; n>>=1; } return 阅读全文
posted @ 2020-11-30 18:41 温暖了寂寞 阅读(71) 评论(0) 推荐(0) 编辑
摘要: bool hasAlternatingBits(int n){ int temp=2; while(n){ if(temp == (n&1)) return false; temp=n&1; n>>=1; } return true; } 阅读全文
posted @ 2020-11-30 16:12 温暖了寂寞 阅读(60) 评论(0) 推荐(0) 编辑
摘要: bool* prefixesDivBy5(int* A, int ASize, int* returnSize){ bool* answer=(bool*)malloc(ASize*sizeof(bool)); int unitSum=0, i; for(i=0; i<ASize; i++){ un 阅读全文
posted @ 2020-11-30 16:01 温暖了寂寞 阅读(81) 评论(0) 推荐(0) 编辑
摘要: int bs(int* nums,int left,int right,int target){ if(left>right) return -1; int mid=(left+right)/2; if(nums[mid] > target){ return bs(nums,left,mid-1,t 阅读全文
posted @ 2020-11-30 14:27 温暖了寂寞 阅读(45) 评论(0) 推荐(0) 编辑
摘要: //C语言DFS void recursion(struct TreeNode* root,int** arr,int* ColumnSizes,int cur,int* returnSize){ if(!root) { if(cur>*returnSize) *returnSize=cur; re 阅读全文
posted @ 2020-11-30 13:57 温暖了寂寞 阅读(77) 评论(0) 推荐(0) 编辑
摘要: void recursion(struct TreeNode* root,char** arr,int* pst,char* s){ if(!root) return; char* temp=(char*)calloc(100,sizeof(char)); strcat(temp,s); if(!( 阅读全文
posted @ 2020-11-30 10:51 温暖了寂寞 阅读(106) 评论(0) 推荐(0) 编辑
上一页 1 ··· 13 14 15 16 17 18 19 20 21 ··· 63 下一页