4.20
public class Solution {
/**
* @param str: a string
* @return: a boolean
*/
public boolean isUnique(String str) {
// write your code here
int length = str.length();
if(length <= 1){
return true;
}
HashMap<Character,Integer> map = new HashMap<Character,Integer>();
for(int i = 0;i<length;i++){
if(!map.containsKey(str.charAt(i))){
map.put(str.charAt(i),1);
}
else{
return false;
}
}
return true;
}
}