【Lintcode209】——第一个只出现一次的字符——给出一个字符串,找出第一个只出现一次的字符。 样例 样例 1: 输入: "abaccdeff" 输出: 'b‘

给出一个字符串,找出第一个只出现一次的字符。 样例 样例 1: 输入: “abaccdeff” 输出: ‘b’ 解释: ‘b’
是第一个出现一次的字符

样例 2: 输入: “aabccd” 输出: ‘b’ 解释: ‘b’ 是第一个出现一次的字符

public class Solution {
    /**
     * @param str: str: the given string
     * @return: char: the first unique character in a given string
     */
    	public char firstUniqChar(String str) {
        // Write your code here
        
        if(str==null){
            return '0';
        }
        
        String[] s = new String[str.length()];
        for(int i = 0;i

重点:将字符串转化为字符串数组

你可能感兴趣的:(Java)