上一页 1 ··· 22 23 24 25 26 27 28 29 30 ··· 63 下一页
摘要: int calculate(char* s){ int x=1,y=0,i; for (i=0; i<strlen(s); i++) { if (s[i]=='A') x=x*2+y; else y=y*2+x; } return x+y; } 阅读全文
posted @ 2020-11-06 15:46 温暖了寂寞 阅读(96) 评论(0) 推荐(0) 编辑
摘要: int factorial(int n){ int ret=1; while(n) ret*=n--; return ret; } int paintingPlan(int n, int k){ if (k==0 || k==n*n) return 1; int blank=n*n-k,ret=0, 阅读全文
posted @ 2020-11-06 13:49 温暖了寂寞 阅读(367) 评论(0) 推荐(0) 编辑
摘要: int Fun(int x){ int res=0; while (x) res+=x&1,x>>=1; return res; } int Mycmp(const void* a,const void* b){ return (Fun(*(int*)a) - Fun(*(int*)b))? Fun 阅读全文
posted @ 2020-11-06 09:04 温暖了寂寞 阅读(66) 评论(0) 推荐(0) 编辑
摘要: void Insertintervals(int* interval, int* returnSize, int** returnColumnSizes, int** ans){ int* tmp = malloc(sizeof(int) * 2); memcpy(tmp, interval, si 阅读全文
posted @ 2020-11-04 23:37 温暖了寂寞 阅读(104) 评论(0) 推荐(0) 编辑
摘要: int findSpecialInteger(int* arr, int arrSize){ for(int i=0; i<arrSize; i++) if(arr[i] == arr[i+arrSize/4]) return arr[i]; return -1; } 阅读全文
posted @ 2020-11-03 23:41 温暖了寂寞 阅读(90) 评论(0) 推荐(0) 编辑
摘要: char * convertToTitle(int n){ char* arr = (char*)calloc(1002, sizeof(char)); int val,pst=1001; while (n){ val = n % 26; if (val == 0) val = 26; arr[-- 阅读全文
posted @ 2020-10-26 01:01 温暖了寂寞 阅读(67) 评论(0) 推荐(0) 编辑
摘要: int trailingZeroes(int n){ int res = 0; while (n) { n /= 5; res += n; } return res; } 阅读全文
posted @ 2020-10-22 17:51 温暖了寂寞 阅读(78) 评论(0) 推荐(0) 编辑
摘要: //C语言双循环遍历 int* fairCandySwap(int* A, int ASize, int* B, int BSize, int* returnSize){ int sumA=0,sumB=0,i,j; int* arr = (int*)calloc(2,sizeof(int)); * 阅读全文
posted @ 2020-10-22 15:56 温暖了寂寞 阅读(145) 评论(0) 推荐(0) 编辑
摘要: //C语言 int fib(int N){ if(N==0) return 0; if(N==1) return 1; int f0=0,f1=1,res,i; for(i=2; i<=N; i++){ res=f0+f1; f0=f1; f1=res; } return res; } /*C++* 阅读全文
posted @ 2020-10-18 19:45 温暖了寂寞 阅读(95) 评论(0) 推荐(0) 编辑
摘要: //C++ class Solution { public: vector<int> finalPrices(vector<int>& prices) { vector<int> arr; int i,j; for(i=0; i<prices.size()-1; i++) { for(j=i+1; 阅读全文
posted @ 2020-10-18 00:17 温暖了寂寞 阅读(187) 评论(0) 推荐(0) 编辑
上一页 1 ··· 22 23 24 25 26 27 28 29 30 ··· 63 下一页