public int lengthOfLongestSubstring(String s) {
        int max = 0;
        int count = 0;
        Queue<Character> subString = new LinkedList<Character>();
        char[] theString = s.toCharArray();
        for (int i = 0; i < theString.length; i++) {
            Character thisChar = theString[i];
            if (subString.contains(thisChar)) {
                max = count > max ? count : max;
                while (!subString.poll().equals(thisChar)) {
                    count--;
                }
                count--;
            }
            subString.offer(thisChar);
            count++;
        }
        max = count > max ? count : max;
        return max;
    }