Open dailiuyang123 opened 2 years ago
public boolean uniqueStr(String astr){
for (int i=0;i<astr.length();i++){
if (astr.lastIndexOf(astr.charAt(i))!=i){
return false;
}
}
return true;
}
public boolean CheckPermutation(String s1, String s2) {
if (s1.length() != s2.length()) {
return false;
}
char[] c1 = s1.toCharArray();
char[] c2 = s2.toCharArray();
Arrays.sort(c1);
Arrays.sort(c2);
return Arrays.equals(c1,c2);
}
public boolean canPermutePalindrome(String s) {
if(s == null){
return false;
}
char[] chars = s.toCharArray();
Set<Character> set = new HashSet<>();
for(char c : chars){
if(set.contains(c)){
set.remove(c);
}else{
set.add(c);
}
}
return set.size() <= 1;
}
leetcode 字符串类
https://leetcode-cn.com/problems/is-unique-lcci/