Below is a solution -
#include <stdio.h>
int main(int argc, char* argv[]){
int i = 0;
char *array = argv[1];
char prev = array[0];
while(array[i]){
int count = 0;
while(prev == array[i]){
i +=1;
count++;
}
printf("%d%c,",count,prev);
prev = array[i];
}
printf("\n");
}
Regards
Abhijeet Srivastva
On Wed, Aug 10, 2011 at 9:04 AM, monish001 <[email protected]> wrote:
> Given : ddaaaabbccae
> O/P : 2d4a2b2c1a1e
> What is happening? What algo?
>
> Thanks and regards
> Monish
>
> On Aug 9, 5:59 pm, ankit sambyal <[email protected]> wrote:
> > Given an array of characters, change the array to something as shown in
> the
> > following example.
> > Given : ddaaaabbccae
> > O/P : 2d4a2b2c1a1e
> >
> > Do it in the most efficient manner both in terms of time and space ...
>
> --
> 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.