摘要:
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
温暖了寂寞
阅读(77)
评论(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
温暖了寂寞
阅读(65)
评论(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
温暖了寂寞
阅读(86)
评论(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
温暖了寂寞
阅读(49)
评论(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
温暖了寂寞
阅读(85)
评论(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
温暖了寂寞
阅读(112)
评论(0)
推荐(0)
摘要:
int recursion(struct TreeNode* root,int* sum){ if(!root) return 0; int left=recursion(root->left,sum); int right=recursion(root->right,sum); (*sum) += 阅读全文
posted @ 2020-11-30 09:17
温暖了寂寞
阅读(79)
评论(0)
推荐(0)

浙公网安备 33010602011771号