题目:
给定输入asv<<bd< 输出 asb,输入xdb<yxh<z输出xdyxz
public static String process(String input) {
char[] tempArray = new char[input.length()];
int count = 0;
char[] array = input.toCharArray();
for (char c : array) {
if (c == '<' && count > 0) {
count--;
} else {
tempArray[count] = c;
count++;
}
}
StringBuilder sb = new StringBuilder();
for (int i = 0; i < count; i++) {
sb.append(tempArray[i]);
}
return sb.toString();
}