Re: [algogeeks] Re: remove duplicate words in a string
@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 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 > occured > if the encountered s[i] has corresponding array[s[i]]==0 =>this char > has not occured yet > else > delete dat particular char at pos 'i' n decrement i > > -- > 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. > > -- 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.
Re: [algogeeks] Re: remove duplicate words in a string
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--; > } > } > > > > } > > -- > 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. > > -- Mithun.B.S M:9916775380 -- 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.
Re: [algogeeks] Re: remove duplicate words in a string
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 > 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 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 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 > 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. > >> > >> > >> > >> -- > >> Saurabh Singh > >> B.Tech (Computer Science) > >> MNNIT ALLAHABAD > >> > >> > >> -- > >> 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. > > > > > > > > -- > > best wishes!! > > Vaibhav > > MCA > > > > -- > > 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. > > > > > > -- > Gaurav Menghani > > -- > 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. > > -- best wishes!! Vaibhav MCA -- 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.
Re: [algogeeks] Re: remove duplicate words in a string
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 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 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 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. >> >> >> >> -- >> Saurabh Singh >> B.Tech (Computer Science) >> MNNIT ALLAHABAD >> >> >> -- >> 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. > > > > -- > best wishes!! > Vaibhav > MCA > > -- > 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. > -- Gaurav Menghani -- 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.
Re: [algogeeks] Re: remove duplicate words in a string
@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 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 this group, send email to > algogeeks+unsubscr...@googlegroups.com. > 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 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.
Re: [algogeeks] Re: remove duplicate words in a string
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 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 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. >> > > > > -- > Saurabh Singh > B.Tech (Computer Science) > MNNIT ALLAHABAD > > > -- > 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. > -- best wishes!! Vaibhav MCA -- 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.
Re: [algogeeks] Re: remove duplicate words in a string
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 this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: remove duplicate words in a string
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 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 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. > -- Saurabh Singh B.Tech (Computer Science) MNNIT ALLAHABAD -- 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.
Re: [algogeeks] Re: remove duplicate words in a string
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 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.
Re: [algogeeks] Re: remove duplicate words in a string
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. >>> >>> 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@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. >>> >>> >> >> >> -- >> best wishes!! >> Vaibhav >> MCA >> >> >> -- >> 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. >> > > -- > 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. > -- best wishes!! Vaibhav MCA -- 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.
Re: [algogeeks] Re: remove duplicate words in a string
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 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@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. >> >> > > > -- > best wishes!! > Vaibhav > MCA > > > -- > 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. > -- 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.
Re: [algogeeks] Re: remove duplicate words in a string
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 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. > > -- best wishes!! Vaibhav MCA -- 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.