[Java] Prefix + Bitmask O(11*N)
\nclass Solution {\n    public int longestAwesome(String s) {\n        HashMap<Integer, Integer> map = new HashMap();\n        int fHash = 0;\n        int n = s
```\nclass Solution {\n    public int longestAwesome(String s) {\n        HashMap<Integer, Integer> map = new HashMap();\n        int fHash = 0;\n        int n = s.length();\n        int res = 0;\n        map.put(fHash, -1);\n        for(int i=0; i<n; i++){\n            int cIndex = s.charAt(i)-\'0\';\n            fHash = fHash^(1<<cIndex);\n            res = Math.max(i-map.getOrDefault(fHash, i), res);\n            for(int j=0; j<10; j++){\n                int posHash = 1<<j;\n                int prevHash = fHash^posHash;\n                res = Math.max(i-map.getOrDefault(prevHash, i), res);\n            }\n            map.putIfAbsent(fHash, i);\n        }\n        return res;\n    }\n}\n```
[]