Remove duplicate char in given array
package CrackingCodingInterview;
public class RemoveDupplicateChar {
public static void main(String... args)
{
String input = "randomStringomsdf";
System.out.println(removeDuplicateChar(input));
}
public static String removeDuplicateChar(String s)
{
StringBuilder sbr = new StringBuilder();
for(int i=0; i<s.length();i++)
{
String str = s.substring(i, i+1);
if(sbr.indexOf(str) == -1)
{
sbr.append(str);
}
}
return sbr.toString();
}
}