Re: [algogeeks] remove duplicate chars in a string without using extra memory

2011-07-11 Thread dinesh bansal
On Sat, May 28, 2011 at 11:32 AM, Rajeev Kumar wrote: > Design an algorithm and write code to remove the duplicate characters in a > string without using any additional buffer. >  NOTE: One or two additional variables are fine. >  An extra copy of the array is not. > > -- > Thank You > Rajeev Kuma

Re: [algogeeks] remove duplicate chars in a string without using extra memory

2011-06-05 Thread Gaurav Aggarwal
please explain the logic behind your code :) On Sat, Jun 4, 2011 at 2:36 AM, Aakash Johari wrote: > @Lalit: This requires a simple modification. You can take the following > one: > > #include >> >> int main() >> { >> unsigned long long int a = 0; >> char str[50]; >> int i, j; >> >>

Re: [algogeeks] remove duplicate chars in a string without using extra memory

2011-06-03 Thread Aakash Johari
Yes, it can be.. i could make it obfuscated and produce a code with lesser number of characters. :) but i tried to make it understandable. On Fri, Jun 3, 2011 at 3:21 PM, hary rathor wrote: > Akash your code is good but it can be code more short > > #include > > int main() > { > unsigned lo

Re: [algogeeks] remove duplicate chars in a string without using extra memory

2011-06-03 Thread hary rathor
Akash your code is good but it can be code more short #include int main() { unsigned long long int a = 0; char str[]="harish chandra pran"; int i, j; for ( i = j = 0; str[i]; i++ ) { int offset=0; if ( str[i] >= 'a' && str[i] <= 'z' ) offset=26; offse

Re: [algogeeks] remove duplicate chars in a string without using extra memory

2011-06-03 Thread Aakash Johari
@Lalit: This requires a simple modification. You can take the following one: #include > > int main() > { > unsigned long long int a = 0; > char str[50]; > int i, j; > > scanf ("%s", str); > > for ( i = j = 0; str[i]; i++ ) { > if ( str[i] >= 'A' && str[i] <= 'Z' ) { >

Re: [algogeeks] remove duplicate chars in a string without using extra memory

2011-06-03 Thread LALIT SHARMA
@Johari , You have correctly mapped but the question demanded , to remove all repetition , though the string is still the same as it was given in input . On Fri, Jun 3, 2011 at 7:00 PM, Kunal Patil wrote: > If you are not going to allow extra space, you have to compromise on time > complexity.

Re: [algogeeks] remove duplicate chars in a string without using extra memory

2011-06-03 Thread Kunal Patil
If you are not going to allow extra space, you have to compromise on time complexity..[?] If you dont have your string already stored in a trie/hashmap usage of it requires additional buffer. Simple solution would be: Sort given string using in-place sorting algorithm and then removal of duplicate

Re: [algogeeks] remove duplicate chars in a string without using extra memory

2011-06-02 Thread Aakash Johari
It was given that one or two extra variables are allowed. So I used a variable instead for mapping. It is simply mapping of each character in alphabet to a bit in the variable. On Thu, Jun 2, 2011 at 7:10 AM, Ashish Goel wrote: > using bitmap, but extra memory not allowed? > > > Best Regards >

Re: [algogeeks] remove duplicate chars in a string without using extra memory

2011-06-02 Thread Ashish Goel
using bitmap, but extra memory not allowed? Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 On Thu, Jun 2, 2011 at 7:38 PM, Ashish Goel wrote: > what is the logic, kindly explain > Best Regards > Ashish Goel > "Think positive and find fuel in fa

Re: [algogeeks] remove duplicate chars in a string without using extra memory

2011-06-02 Thread Ashish Goel
what is the logic, kindly explain Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 On Sat, May 28, 2011 at 12:23 PM, Aakash Johari wrote: > Following code works for [A-Za-z], can be extended for whole character-set > : > >> #include >> >> int main()

Re: [algogeeks] remove duplicate chars in a string without using extra memory

2011-05-27 Thread Aakash Johari
Following code works for [A-Za-z], can be extended for whole character-set : > #include > > int main() > { > unsigned long long int a = 0; > char str[50]; > int i; > > scanf ("%s", str); > > for ( i = 0; str[i]; i++ ) { > if ( str[i] >= 'A' && str[i] <= 'Z' ) { >

Re: [algogeeks] remove duplicate chars in a string without using extra memory

2011-05-27 Thread saurabh singh
string getStringWithoutDuplicateChars(string input) { create_empty_trie_ds (say trie) integer count = 0; for_each_char_in_string (say ch) { if(trie->contains(ch)) //if ch not there in ds then add it and return false otherwise return true { input.remove(count) } count++

[algogeeks] remove duplicate chars in a string without using extra memory

2011-05-27 Thread Rajeev Kumar
Design an algorithm and write code to remove the duplicate characters in a string without using any additional buffer. NOTE: One or two additional variables are fine. An extra copy of the array is not. -- Thank You Rajeev Kumar -- You received this message because you are subscribed to the G