Anika, look closely.
Your code takes O(N^2) instead of O(N)

Regards,
Sandeep Jain



On Mon, Jul 11, 2011 at 5:15 PM, Anika Jain <anika.jai...@gmail.com> wrote:

> YA.. N YA M USING 2 VARIABLES.. IS IT ALLOWED?
>
>
> On Mon, Jul 11, 2011 at 4:58 PM, saurabh singh <saurab...@gmail.com>wrote:
>
>> A similar solution has been proposed above if I am not misinterpreting the
>> code,You are creating a bitmap from the 2 variables.?
>>
>>
>> On Mon, Jul 11, 2011 at 4:55 PM, Anika Jain <anika.jai...@gmail.com>wrote:
>>
>>>
>>> A c code for this is:
>>>
>>> int main()
>>> {
>>>     int a[2] = {0};
>>>     char str[50];
>>>         int i,ind=0;
>>>     scanf ("%s", str);
>>>     for(i=0;i<strlen(str);i++)
>>>     {
>>>
>>>         if(str[i]>='a' && str[i]<='z')
>>>         {
>>>             if(!(a[0] & 1<<str[i]-'a'))
>>>             {
>>>                 a[0] = a[0] | 1<<str[i]-'a';
>>>                 str[ind]=str[i];
>>>                 ind++;
>>>             }
>>>         }
>>>         else if(str[i]>='A' && str[i]<='Z')
>>>         {
>>>             if(!(a[1] & 1<<str[i]-'a'))
>>>             {
>>>                 a[1] = a[1] | 1<<str[i]-'a';
>>>                 str[ind]=str[i];
>>>                 ind++;
>>>             }
>>>         }
>>>     }
>>>     str[ind]='\0';
>>>
>>>     printf("%s\n",str);
>>>     return 0;
>>> }
>>>
>>>
>>> is it fine 2 use 2 integers for this? or not allowed??
>>>
>>>
>>>
>>> On Mon, Jul 11, 2011 at 9:35 AM, Yaw <yawbrob...@gmail.com> wrote:
>>>
>>>> Quite new to java what do you think of mine?
>>>>
>>>> import java.util.*;
>>>>
>>>> public class RemoveDuplicates {
>>>>
>>>>
>>>>     public static void main(String[] args){
>>>>         while(true) {
>>>>         System.out.println("Enter String");
>>>>         Scanner input = new Scanner(System.in);
>>>>         String str = input.nextLine();
>>>>         System.out.println(RemoveDup(str));
>>>>         }
>>>>     }
>>>>
>>>>     public static String RemoveDup(String str){
>>>>         str = str.toLowerCase();
>>>>         String temp = "";
>>>>          for (int i=0; i<str.length(); i++){
>>>>              if (!temp.contains(Character.toString(str.charAt(i)))){
>>>>                  temp+=str.charAt(i);
>>>>              }
>>>>
>>>>          }
>>>>          return temp;
>>>>
>>>>
>>>>     }
>>>>
>>>> }
>>>>
>>>>
>>>
>>>
>>>>  --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Algorithm Geeks" group.
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msg/algogeeks/-/vD7vwu7Fz_oJ.
>>>>
>>>> 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.
>>>
>>
>>
>>
>> --
>> 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.
>>
>
>  --
> 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.

Reply via email to