Girish
BAN USERhey puneet.. nothing offensive here.. I just tried following your algorithm blindly as I had only 15 min to solve but couldn't get the desired answer.. better I post my code here.. may be I am wrong here.. you can help me out where I went wrong.. thanks :-)
boolean[] barray = new boolean[256];
for(int i=0;i<str3.length();i++)
{
char c= str3.charAt(i);
barray[c] = true;
}
for(int i=0;i<str1.length();i++)
{
if (barray[str1.charAt(i)]== true)
str1=str1.replaceAll(Character.toString(str1.charAt(i)), "");
}
System.out.println(str1);
boolean[] bary = new boolean[256];
for(int i=0;i<str2.length();i++)
{
char c= str2.charAt(i);
bary[c] = true;
}
StringBuilder sb=new StringBuilder();
for(int i=0;i<str1.length();i++)
{
if (bary[str1.charAt(i)]== true)
sb.append(str1.charAt(i));
}
System.out.println(sb.toString());
As I said, I blindly followed your steps without thinking much on logic because of time constraint. May be you could've explained more in your steps.
- Girish April 22, 2014