class Solution {
public:
int binaryGap(int N) {
int res = 0;
int count = 0;
bool flag = false;
while(N>0){
if((N&1) ==1){
flag =true;
N >>=1;
res = max(res,count);
count =1;
}
else {
N >>=1;
if (flag)
count +=1;
}
}
return res;
}
};
(N&1)需要加括号,优先级比==低