YA.. N YA M USING 2 VARIABLES.. IS IT ALLOWED? On Mon, Jul 11, 2011 at 4:58 PM, saurabh singh <[email protected]> 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 <[email protected]>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 <[email protected]> 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 [email protected]. >>> To unsubscribe from this group, send email to >>> [email protected]. >>> 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 [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> 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 [email protected]. > To unsubscribe from this group, send email to > [email protected]. > 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
