LintCode 157---判断字符串是否没有重复字符

public class Solution {
    /*
     * @param str: A string
     * @return: a boolean
     */
     public static boolean isUnique(String str) {
        if(str.length() == 1)
            return true;
        for (int i = 0; i < str.length(); i++) {
            for (int j = i+1; j < str.length(); j++) {
                if(str.charAt(i) == str.charAt(j)) 
                    return false;
            }
        }
        return true;
    }
}

 

你可能感兴趣的:(LintCode 157---判断字符串是否没有重复字符)