LeeCode_判定字符是否唯一
作者:互联网
class Solution {
public boolean isUnique(String astr) {
boolean flag = true;
int count = astr.length();
if (count != 0 || count != 1){
for (int i = 0; i < count; i++){
if (astr.indexOf(astr.charAt(i)) != astr.lastIndexOf(astr.charAt(i))){ // 利用索引判断从左从右索引值是否相同
flag = false;
}
}
}
return flag;
}
}
标签:count,字符,charAt,int,flag,LeeCode,boolean,判定,astr 来源: https://www.cnblogs.com/Neil-J/p/13557770.html