@akshata sharma:
Kindly post a new question as a separate thread and not as a reply to
an existing one so tat it would be noticed by many ppl!
As akash suggestd, use a bit vector called 'visited' of 26 size for
ASCII or of a larger size in case of Unicode ( still constant space
and i dont think declaring 26 variables counts as an additional DS!!),
if visited then , ignore the character while processing.
a simple algorithm,
int last_ptr=0;
for ( i = 0 - N )
{
if(visited(a[i])) continue;
else a[last_ptr++]=a[i];
visited(a[i]) = true;
}
a[last_ptr]=NULL;
print (%s,a) ;



On Jul 23, 12:56 pm, Akshata Sharma <akshatasharm...@gmail.com> wrote:
> better than O(n^2)..
>
> On Sat, Jul 23, 2011 at 1:08 PM, Akshata Sharma
> <akshatasharm...@gmail.com>wrote:
>
>
>
>
>
>
>
> > Given a string *Str of ASCII characters, write the pseudo code to remove
> > the duplicate elements present in them. For example, if the given string is
> > "Potato", then, the output has to be "Pota". Additional constraint is, the
> > algorithm has to be in-place( no extra data structures allowed) . Extend
> > your algorithm to remove duplicates in the string which consisted of UNICODE
> > characters.

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