LeetCode.面试题01.01.判断字符是否唯一(Java实现)

class Solution {                       //双指针暴力解法
    public boolean isUnique(String astr) {
        boolean isSame = true;
        for(int i = 0; i < astr.length() - 1; i++)
        {
            for(int j = i + 1; j < astr.length(); j++)
            {
                if(astr.charAt(i) == astr.charAt(j))
                {
                    return false;
                }
            }
        }

        return isSame;
    }
}

发布了31 篇原创文章 · 获赞 1 · 访问量 1271

猜你喜欢

转载自blog.csdn.net/qq_45824565/article/details/104457067
今日推荐