上一页 1 2 3 4 5 6 7 8 ··· 63 下一页
摘要: int lastRemaining(int n){ return (n==1)?1 :2 * (n/2 - lastRemaining(n/2) + 1); } int lastRemaining(int n){ int stack[100]={0}, pst=-1, i, res=1; for(i 阅读全文
posted @ 2021-02-04 16:29 温暖了寂寞 阅读(59) 评论(0) 推荐(0) 编辑
摘要: #define max(a,b) ((a)>(b))?(a):(b) int integerBreak(int n){ int dp[58]={0}, i, j; dp[1]=1; for(i=2; i<=n; i++){ for (j=1; j<=i/2; j++){ dp[i]= max( dp 阅读全文
posted @ 2021-01-28 18:08 温暖了寂寞 阅读(48) 评论(0) 推荐(0) 编辑
摘要: bool increasingTriplet(int* nums, int numsSize){ int max=nums[0], min=nums[0], i, cnt=1; for(i=1; i<numsSize && cnt<3; i++){ if(nums[i]>max){ cnt++; m 阅读全文
posted @ 2021-01-24 12:08 温暖了寂寞 阅读(78) 评论(0) 推荐(0) 编辑
摘要: struct st { int pre; int prepre; }; #define max(a,b) ((a)>(b))?(a):(b) struct st recursion(struct TreeNode* root){ if(!root){ return (struct st){0,0}; 阅读全文
posted @ 2021-01-24 11:51 温暖了寂寞 阅读(52) 评论(0) 推荐(0) 编辑
摘要: void wiggleSort(int* nums, int numsSize){ int hash[5001]={0}, i, j=0; for(i=0; i<numsSize; i++) hash[nums[i]]++; i=(numsSize%2)?numsSize-1 :numsSize-2 阅读全文
posted @ 2021-01-24 11:33 温暖了寂寞 阅读(52) 评论(0) 推荐(0) 编辑
摘要: int cmp(const void* a, const void* b){ return *(int*)b - *(int*)a; } void recursion(int* coins,int coinsSize,int amount,int cur,int sum,int cnt,int* m 阅读全文
posted @ 2021-01-22 20:39 温暖了寂寞 阅读(82) 评论(0) 推荐(0) 编辑
摘要: /*只有完全平方数的因数数量是奇数,奇数灯亮,偶数灯灭*/ int bulbSwitch(int n){ return sqrt(n); } 阅读全文
posted @ 2021-01-22 11:17 温暖了寂寞 阅读(68) 评论(0) 推荐(0) 编辑
摘要: #define INT_MAX 2147483647 int nthSuperUglyNumber(int n, int* primes, int primesSize){ if(n == 1) return 1; int *res = (int *)calloc(n, sizeof(int)); 阅读全文
posted @ 2021-01-20 14:52 温暖了寂寞 阅读(73) 评论(0) 推荐(0) 编辑
摘要: char* removeDuplicateLetters(char* s) { int vis[26], num[26]; memset(vis, 0, sizeof(vis)); memset(num, 0, sizeof(num)); int n = strlen(s); for (int i 阅读全文
posted @ 2021-01-15 20:47 温暖了寂寞 阅读(88) 评论(0) 推荐(0) 编辑
摘要: int hIndex(int* citations, int citationsSize){ if(citationsSize==0) return 0; int i,cnt=0; for(i=citationsSize-1; i>=0 && citations[i]>0 && citationsS 阅读全文
posted @ 2021-01-08 21:38 温暖了寂寞 阅读(47) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 ··· 63 下一页