JAVA 判断字符串有无重复字符 程序员面试金典

判断字符串有无重复字符

题目来源:
程序员面试金典

java题解:

	public static boolean checkDifferent(String iniString){
        if (iniString.isEmpty()){
            return true;
        }
        int[] flag=new int[128];

        for (int i = 0; i < iniString.length(); i++) {
            int c=(int)iniString.charAt(i);
            if (flag[c]>0){
                return false;
            }
            flag[c]++;
        }
        return true;
    }
发布了8 篇原创文章 · 获赞 2 · 访问量 188

猜你喜欢

转载自blog.csdn.net/qq_41961609/article/details/105103964
今日推荐