I could not get it for recursively, but iteratively, I coded a solution. If
anyone knows recursively,
let us know please.
#include<stdio.h>
void main()
{
char s[18]="DGGDBCBHH";
int i=0,j=0;
int count;
while(s[i]!='\0')
{
if(s[i] == s[i+1])
{
count = strlen(s)-2;
while(count--)
{
s[i]=s[i + 2];
i++;
}
s[i]='\0';
i=0;
}
else
{
i++;
}
}
printf("%s",s);
getch();
}
I/P: DGGDBCBHH O/P: BCB
Best Regards
Abhijit
On Sun, Feb 6, 2011 at 1:47 PM, ramkumar santhanam
<[email protected]>wrote:
> use stack.
>
> --
> 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.
>
--
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.