here is my approach
where i left the non repeating characters as it is and done some good code..
char * runlengthencode(char* str,int size)
{
int i,j,flag=0;
for(i=0,j=1;str[i]&&str[j]&&j<size;i++,j++)
{
while(str[i]==str[j])
{
j++;
flag=1;
}
if(flag)
{
j=j-1;
str[i+1]=48+(j-i+1);
flag=0;
i=j;
j++;
}
}
return str;
}
On Sat, Sep 3, 2011 at 6:54 PM, Aman Kumar <[email protected]> wrote:
> Hiii
> if array is given like this
>
> arr[]=aabcabbcdeadef
>
> convert this array into like
>
> arr[]=a4b3c2d2e2f1
>
> how can we do this
>
> can we do it with space complexity O(1).
>
> reply asap
>
> --
> 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.