@ 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 <[email protected]>wrote: > 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, SAMM <[email protected]> wrote: > >> 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 1st node "a1b2c3d4". >> end -> store the end node of the input string . >> outputbegin -> store the position where the output index begin .. It will >> be appended to the next node of the input string . >> outputend ->store the end node of the LL. >> >> begin --> a 1 b 2 c 3 d 4(<-end) (outputbegin->) NULL <-(outputend) >> >> Delete d4 we hav now:- >> begin --> a 1 b 2 c 3 (<-end) (outputbegin->) d d d d <-(outputend) >> >> Take the character and corresponding value from the end index, change the >> end pointer to '3' on the left of "d4" , delete both nodes of "d4" and >> append it characters at the end .. All u have to do is remove and append , >> no extra memory greater than length(output) is used here .. >> >> As Nothing has been mentioned abt printing the output in the question , >> we will keep printing the character on the console while appendiing the >> character in the LL ). >> >> -- >> 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. >> > > > > -- > > > *Kalyan > > Dont take life seriously as it isnt Permanent! > > * > > -- > 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.
