We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
int main(){
int n;
int max=0,count=0;
cin >> n;
int binary[100];
int c=0,m=0;
while(n>0){
int i=1;
int rem=n%2;
n=n/2;
if(rem==1){
count++;
if(count>max)
max=count;
}
else
count=0;
}
cout<<max;
return 0;
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Day 10: Binary Numbers
You are viewing a single comment's thread. Return to all comments →
int main(){ int n; int max=0,count=0; cin >> n; int binary[100]; int c=0,m=0; while(n>0){ int i=1; int rem=n%2; n=n/2; if(rem==1){ count++; if(count>max) max=count; } else count=0; }
}