题目来源:
题目描述:
代码如下:
public class Solution {
int[] hashtable = new int[256];
StringBuilder sc = new StringBuilder();
public void Insert(char ch) {
sc.append(ch);
if (hashtable[ch] == 0) {
hashtable[ch] = 1;
} else {
hashtable[ch] += 1;
}
}
public char FirstAppearingOnce() {
char[] str = sc.toString().toCharArray();
for (char s : str) {
if (hashtable[s] == 1) {
return s;
}
}
return '#';
}
}