public static int lengthOfLongestSubstring(String s) {
		int max = 0;
		int len = s.length();
		int[] hash = new int[256];
		int[] first = new int[len+1];
		int[] next = new int[len];
		first[len] = len;
		for (int i = len - 1; i >= 0; i--) {
			int index = hash[s.charAt(i)];
			next[i] = index == 0 ? len : index;
			hash[s.charAt(i)] = i;
			if (first[i + 1] > next[i]) {
				first[i] = next[i];
			} else {
				first[i] = first[i + 1];
			}
		}
		for (int i = 0; i < len; i++) {
			if (first[i] - i > max) max = first[i] - i;
		}
		return max;
	}