无重复字符串的长度
作者:bin给定一个字符串,请你找出其中不含有重复字符串的「最长字符串」的长度
例如:asdcsasdecxc
长度:6
@Test
public void test(){
String data = "asdcsasdecxc";
Map<Character,Integer> has = Maps.newHashMap();
HashSet a = new HashSet<>();
Integer max = 0;
for (int i = 0; i< data.length(); i++){
Character tmp = data.charAt(i);
if (has.containsKey(tmp)){
max = Math.max(max, i - has.get(tmp));
has.replace(tmp, i);
}
has.put(tmp, i);
}
System.out.println(max);
}