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
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;
>>
>>
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
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
@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' ) {
>
@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.
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
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
>
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
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()
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' ) {
>
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++
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
13 matches
Mail list logo