public class Different { public boolean checkDifferent(String iniString) { LinkedHashMap<Character, Integer> map = new LinkedHashMap<Character, Integer>(); char[] ch = iniString.toCharArray(); for (int i = 0; i < ch.length; i++) { if (map.containsKey(ch[i])) { int time = map.get(ch[i]); map.put(ch[i], ++time); } else map.put(ch[i], 1); }
for (int i = 0; i < ch.length; i++) { if (map.get(ch[i]) > 1) return false; } return true;
近期评论