Hope this works
http://ideone.com/MCLqO
On Sun, Mar 25, 2012 at 4:37 PM, atul anand wrote:
> @ Kalyanasundaram : no need to check you algo , bcozz i can clearly see
> you are not saving output to the bufffer , you are just printing it to
> stdout .
> please read prev comment for better understan
@ Kalyanasundaram : no need to check you algo , bcozz i can clearly see you
are not saving output to the bufffer , you are just printing it to stdout .
please read prev comment for better understanding the problem,
On Sun, Mar 25, 2012 at 11:54 AM, Kalyanasundaram wrote:
>scanf("%s",a);
>
loop
> a1b2ccc- here we have to do a)reallocation and b)copy the last 3
> from next one it is more swaps :D i hope it can be optimised by some
> way.
>
> not sure though.
>
>
> --
> *From:* Ashish Goel
> *To:* algogeeks@googlegroups.com
> *Sent:* Saturday, 24 March
scanf("%s",a);
l=strlen(a);
for(i=l-1;i>=0;i-=2)
{
while((a[i]--)-'0')
printf("%c",a[i-1]);
}
This works fine when the count of characters is a <10 .Also no extra space
used.If you find any mistake, please do correct me!
On Sun, Mar 25, 2012 at 10:18 AM, SAM
'ee' left side by 1
From: atul anand
To: algogeeks@googlegroups.com
Sent: Saturday, 24 March 2012 4:32 PM
Subject: Re: [algogeeks] Re: Run Length Decoding... inplace
@raghavan: wont work...take input as a1b1c4...it willl fail.
read
In this question is it mandatory to use array here .Because the output and
the space were the string is stored is required ..
I was thinking of using LL approach ..
Need four pointers to keep track of the positions .
begin -> store the beginning of the LL initially containing the pointer to
he 1
@ashish:
i guess you are thinking too much , question say you have character 'a' to
'z' and some value after which will tell ,how many times you shuld print it.
if we take 15 as 1 then this would require other means of encoding
to interpret it correctly.
On Sat, Mar 24, 2012 at 1:19 AM, As
>
> --
> *From:* Ashish Goel
> *To:* algogeeks@googlegroups.com
> *Sent:* Saturday, 24 March 2012 1:19 AM
> *Subject:* Re: [algogeeks] Re: Run Length Decoding... inplace
>
> Atul
>
>
>
> a10 looks good however, when there are multiple su
next one it is more swaps :D i hope it can be optimised by some way.
not sure though.
From: Ashish Goel
To: algogeeks@googlegroups.com
Sent: Saturday, 24 March 2012 1:19 AM
Subject: Re: [algogeeks] Re: Run Length Decoding... inplace
Atul
a10 looks good
Atul
a10 looks good however, when there are multiple such cases within the same
string, it is is a problem because i would not know if the char is the real
character of the string or part ofthe length
eg
a10115
is a valid string and can be interpreted as a01 or a 10115 times.
RLE is the fi
@utkarsh: +1
On 23 Mar 2012 18:38, "UTKARSH SRIVASTAV" wrote:
> I am considering that I am having total size of buffer that is maximum of
> output or input buffer and input is given in the buffer.
>
> My first approach of the solution was that
> 1. first traverse whole array and then count total
Yes u are correct...My bad...That obviously didn't made any sense
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com
On Fri, Mar 23, 2012 at 7:49 PM, UTKARSH SRIVASTAV
wrote:
> yes if we use char instead of that place then again we will loss the data
> on the i
yes if we use char instead of that place then again we will loss the data
on the input a1b1c4
On Fri, Mar 23, 2012 at 7:42 PM, saurabh singh wrote:
> what if we simply use the same char instead of '\0' that would reduce one
> traversal?
> (@utkarsh We discussed that earlier in lab.Did u found ou
what if we simply use the same char instead of '\0' that would reduce one
traversal?
(@utkarsh We discussed that earlier in lab.Did u found out the bug in this
approach?)
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com
On Fri, Mar 23, 2012 at 6:38 PM, UTKARSH
I am considering that I am having total size of buffer that is maximum of
output or input buffer and input is given in the buffer.
My first approach of the solution was that
1. first traverse whole array and then count total number of characters
that will be present in whole array. O(n)
2. fill th
@Ashish : a10 will be represented as aa . Here '1' and '0' are
character type in the given input , so you need to convert it into numeric
10.
On Thu, Mar 22, 2012 at 1:09 AM, Ashish Goel wrote:
> Gene, Atul
>
> How would a string of say 257 or say 10 times a would be represented, will
>
Gene, Atul
How would a string of say 257 or say 10 times a would be represented, will
it be a10 or a
Best Regards
Ashish Goel
"Think positive and find fuel in failure"
+919985813081
+919966006652
On Wed, Mar 21, 2012 at 2:04 PM, atul anand wrote:
> wasnt able to come up with an algo which woul
wasnt able to come up with an algo which would satisfy all the cases input
like a1b1c4 here output length is equal to input length . till now i dont
knw how to handle these type of input. :( :(
On Wed, Mar 21, 2012 at 10:02 AM, atul anand wrote:
> @Gene : yes you are right , i misunderstood the p
@Gene : yes you are right , i misunderstood the problem . so m/m available
is just enough to hold the output.
thanks for correcting ... that would make this ques little interesting :)
:)...i guess my first posted code can be modified to meet the requirement.
i will post the updated code.
On Tue, M
using Gene logic , but we need to take care of number with more than 1
digits , so updated gene's code is as follows :-
#include
#define MAX 1000
int copy(char *str,int len)
{
int max_len=MAX-1,i;
for(i=len-1;i>=0;i--)
{
str[max_len]=str[i];
max_len--;
}
return max_l
this will work even if run length is 1.
#include
#define MAX 1000
int copy(char *str,int len)
{
int max_len=MAX-1,i;
for(i=len-1;i>=0;i--)
{
str[max_len]=str[i];
max_len--;
}
return max_len+1;
}
void runLength(char *str)
{
unsigned int j,k=1,loop=0,res_len=0;
int i,n_
21 matches
Mail list logo