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 <monish.gup...@gmail.com> wrote:

> Given : ddaaaabbccae
> O/P : 2d4a2b2c1a1e
> What is happening? What algo?
>
> Thanks and regards
> Monish
>
> On Aug 9, 5:59 pm, ankit sambyal <ankitsamb...@gmail.com> 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 algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> 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 algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to