it is a program for removing duplicate characters from a string ...
i just don't understand what flag[str[cur]]
it refers to...
class Cc1_3 {
static String removeDup(String target) {
if (target == null) return null;
if (target.length() <= 1) return target;
char[] str = target.toCharArray();
boolean[] flag = new boolean[256];
int tail = 0;
int cur = 0;
while (cur < str.length) {
if (flag[str[cur]] == false) {
flag[str[cur]] = true;
str[tail] = str[cur];
tail++;
cur++;
} else cur++;
}
return new String(str, 0, tail);
}
public static void main(String[] args) {
String test = "aabcdeaefgf";
System.out.println(removeDup(test));
}
}