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
おすすめ