https://leetcode.com/problems/longest-substring-without-repeating-characters/
class Solution {
public int lengthOfLongestSubstring(String s) {
if (s.length() == 0) return 0;
Map<String, Integer> map = new HashMap();
int ans = Integer.MIN_VALUE;
int tail = 0;
for (int head = 0; head < s.length(); head++) {
String tmp = Character.toString(s.charAt(head));
if (map.containsKey(tmp)) tail = Math.max(tail, map.get(tmp) + 1);
map.put(tmp, head);
ans = Math.max(ans, head - tail + 1);
}
return ans;
}
}