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 subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.