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 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