Home > Algorithms > Remove the repeated characters in that string and print in same order

Remove the repeated characters in that string and print in same order

July 7, 2012

private static String removeRepeatedChar(String s) {
// TODO Auto-generated method stub

int a[] = new int[256];
String removedString = new String();
for(int i=0;i
char c = s.charAt(i);
if(a[c]==0) {
removedString+=c;
a[c]=1;
}

}
return removedString;
}
Advertisements
Categories: Algorithms
%d bloggers like this: