public class Solution {
LinkedHashSet<Character> set = new LinkedHashSet<>();
//Insert one char from stringstream
public void Insert(char ch) {
if (set.contains(ch))
set.remove(ch);
else
set.add(ch);
}
//return the first appearence once char in current stringstream
public char FirstAppearingOnce() {
if (set.isEmpty()) return '#';
return set.iterator().next();
}
} 
京公网安备 11010502036488号