Re: [algogeeks] 1s and 0s

2010-12-21 Thread mo...@ismu
count the no of bits lets say n then answer becomes 2^n-1 -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@

Re: [algogeeks] 1s and 0s

2010-12-21 Thread Ankur Khurana
I hope the code is self explainatory. int main() { //num is the number int prev =1, next=1,count=0; while(num) { if(count>1) { print false break; } prev=next; next=num%10; num=num/10; if(next!=prev) count++; } if(count<=1) print true } -- You received this message because you are subscr

[algogeeks] 1s and 0s

2010-12-21 Thread snehal jain
I want to see if all the ones in a number appear on the right side of the number and all zeros appear on the left, how can I do this most efficiently? (i.e. 0111 is true but 100010 is false) -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group.