摘要:
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 阅读全文
摘要:
bool hasAlternatingBits(int n){ int temp=2; while(n){ if(temp == (n&1)) return false; temp=n&1; n>>=1; } return true; } 阅读全文
摘要:
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 阅读全文
摘要:
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 阅读全文
摘要:
//C语言DFS void recursion(struct TreeNode* root,int** arr,int* ColumnSizes,int cur,int* returnSize){ if(!root) { if(cur>*returnSize) *returnSize=cur; re 阅读全文
摘要:
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(!( 阅读全文
摘要:
int recursion(struct TreeNode* root,int* sum){ if(!root) return 0; int left=recursion(root->left,sum); int right=recursion(root->right,sum); (*sum) += 阅读全文