1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
public class {
public char firstUniqChar(String str) { int[] freq = new int[256]; for (int i = 0; i < str.length(); i++) { freq[str.charAt(i)]++; } for (int i = 0; i < str.length(); i++) { if (freq[str.charAt(i)] == 1) { return str.charAt(i); } } return Character.MIN_VALUE;
} }
|
近期评论