import java.util.*;


public class Solution {
    /**
     * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
     *
     * 
     * @param s string字符串 
     * @return int整型
     */
    public int lengthOfLongestSubstring(String s) {
        // write code here
        Queue<Character> queue = new LinkedList<>();
        int res = 0;
        for (int i = 0; i < s.length(); i++) {
            char chr = s.charAt(i);
            while (queue.contains(chr)) {
                queue.poll();
            }
            queue.add(chr);
            res = Math.max(res, queue.size());
        }
        return res;
    }
}