第一个只出现一次的字符

题目:

在字符串 s 中找出第一个只出现一次的字符。如果没有,返回一个单空格。 s 只包含小写字母。
示例 1:
输入:s = "abaccdeff"
输出:'b'

示例 2:
输入:s = "" 
输出:' '
class Solution {
    public char firstUniqChar(String s) {
        if(s == null || s.isEmpty()) {
            return ' ';
        }

        char[] ch = s.toCharArray();
        int[] count = new int[26];
        for(char c : ch) {
            count[c - 'a']++;
        }

        for(int i = 0; i < ch.length; i++) {
            int idx = ch[i] - 'a';
            if(count[idx] == 1) {
                return ch[i];
            }
        }

        return ' ';
    }
}