Solution 1:
need two scan :
start from left and replace one by one by non-space character ( thus
have minimal replacemnt)
count =0;
for (int i=0;ilen(str);i++)
{
if(str[i] !=NONSPCECHAR)
{str[count++]=str[i]
}
}
ps: any way it needs Left shift...and all solution must need left
*ptr1=*ptr2=string;
for(i=0;istrlen(string);i++)
if(*str==' ')
ptr2++;
else
{
*ptr1=*ptr2;
ptr1++;
ptr2++;
}
hey guys if anything wrong in this code pls let me know
On Tue, Oct 11, 2011 at 11:04 AM, DIPANKAR DUTTA dutta.dipanka...@gmail.com
wrote:
Can in place compaction be done without left shifts?
--
Nice Day
Abhishek Sharma
Bachelor of Technology
IIT Kanpur (2009)
--
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