@deepika this is a different question, your solution is great for removing
duplicate characters. original question is about removing duplicate words.
On Fri, Aug 5, 2011 at 7:06 PM, deepikaanand wrote:
> ya an array of 256 is surely a wastage of space but this was i couls
> think in my microsoft
ya an array of 256 is surely a wastage of space but this was i couls
think in my microsoft interview as the result should have also been i
place that is
i/p : AAA BBB CCC
o/p:A BC//space should also be removed
::explanantion
s[0] is alwayz unique therfor array[s[0]] = 1 => this char has already
occ
Can you please explain this?
Is array[256] not extra space?
On Fri, Aug 5, 2011 at 5:14 PM, deepikaanand wrote:
> static int array[256];
> removedupli(char s[],int n)
> {
> array[s[0]]=1;
> for(i=1;i {
> if(array[s[i]]==0)
> array[s[i]]=1;
> else
> {
> for(pos=i;i s[pos]=s[pos+1];
> i--;
> }
> }
static int array[256];
removedupli(char s[],int n)
{
array[s[0]]=1;
for(i=1;ihttp://groups.google.com/group/algogeeks?hl=en.
these are the final requirements
Remove duplicate words, no extra space,
On Fri, Aug 5, 2011 at 2:12 PM, Gaurav Menghani
wrote:
> Vaibhav, please don't dynamically alter the requirements of the
> problem :-) Better to say them up front.
>
> On Fri, Aug 5, 2011 at 2:10 PM, vaibhav shukla
> wr
Vaibhav, please don't dynamically alter the requirements of the
problem :-) Better to say them up front.
On Fri, Aug 5, 2011 at 2:10 PM, vaibhav shukla wrote:
> provide a solution whether greater than O(n)
>
> On Fri, Aug 5, 2011 at 2:09 PM, saurabh singh wrote:
>>
>> use maps for implementation
@ankit: agree with ankit..hash table or O(n^2) if no extra space
--
Amol Sharma
Third Year Student
Computer Science and Engineering
MNNIT Allahabad
On Fri, Aug 5, 2011 at 1:39 AM, ankit sambyal wrote:
> If no extra memory is allowed, then I think we can't do better than O(n^2),
> which i
provide a solution whether greater than O(n)
On Fri, Aug 5, 2011 at 2:09 PM, saurabh singh wrote:
> use maps for implementation of hash table...
> if no extra memory allowed then no possible solution within o(n) i
> think.
>
>
> On Fri, Aug 5, 2011 at 2:07 PM, ankit sambyal wrote:
>
>> First
If no extra memory is allowed, then I think we can't do better than O(n^2),
which is pretty straight forward.
--
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
use maps for implementation of hash table...
if no extra memory allowed then no possible solution within o(n) i
think.
On Fri, Aug 5, 2011 at 2:07 PM, ankit sambyal wrote:
> First traverse the string and hash each word into a hash table if it is not
> present in the hash table.
> Then again t
First traverse the string and hash each word into a hash table if it is not
present in the hash table.
Then again traverse the string and hash each word. If the word is not
present in the hash table, output it to the console.
--
You received this message because you are subscribed to the Google G
sorry one more constraint : no extra memory
On Fri, Aug 5, 2011 at 2:03 PM, payel roy wrote:
> Hash table ???
>
> On 5 August 2011 13:58, vaibhav shukla wrote:
>
>> give it in C/C++
>>
>>
>> On Fri, Aug 5, 2011 at 1:57 PM, aj wrote:
>>
>>> you can write a python program to do that easily.
>>>
Using a trie data structure this can be solved in O(n).
read each character of the input string and build a trie. Maintain the
counts of all words.
Now traverse the trie again with the input string and making decisions
whether to print a string depending on the word count that you get
from the tri
Hash table ???
On 5 August 2011 13:58, vaibhav shukla wrote:
> give it in C/C++
>
>
> On Fri, Aug 5, 2011 at 1:57 PM, aj wrote:
>
>> you can write a python program to do that easily.
>>
>> program starts here :
>>
>> c=str.split(raw_input())
>> d=[]
>> for x in c:
>> d[x]=0
>> print li
give it in C/C++
On Fri, Aug 5, 2011 at 1:57 PM, aj wrote:
> you can write a python program to do that easily.
>
> program starts here :
>
> c=str.split(raw_input())
> d=[]
> for x in c:
> d[x]=0
> print list(d)
>
> --
> You received this message because you are subscribed to the Google
you can write a python program to do that easily.
program starts here :
c=str.split(raw_input())
d=[]
for x in c:
d[x]=0
print list(d)
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@
16 matches
Mail list logo