摘要:
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 阅读全文
摘要:
#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 阅读全文
摘要:
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 阅读全文
摘要:
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}; 阅读全文
摘要:
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 阅读全文
摘要:
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 阅读全文
摘要:
/*只有完全平方数的因数数量是奇数,奇数灯亮,偶数灯灭*/ int bulbSwitch(int n){ return sqrt(n); } 阅读全文
摘要:
#define INT_MAX 2147483647 int nthSuperUglyNumber(int n, int* primes, int primesSize){ if(n == 1) return 1; int *res = (int *)calloc(n, sizeof(int)); 阅读全文
摘要:
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 阅读全文
摘要:
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 阅读全文