Deep understanding of Two pointer and intuitive problems
Code\njava []\nclass Solution {\n    \n    public int numberOfSubstrings(String s) {\n        HashMap<Character, Integer> last = new HashMap<>();\n        last.
# Code\n```java []\nclass Solution {\n    \n    public int numberOfSubstrings(String s) {\n        HashMap<Character, Integer> last = new HashMap<>();\n        last.put(\'a\', -1);\n        last.put(\'b\', -1);\n        last.put(\'c\', -1);\n        \n        int res = 0;\n        int n = s.length();\n        \n        for (int i = 0; i < n; ++i) {\n            char c = s.charAt(i);\n            last.put(c, i);\n            \n            res += 1 + Math.min(last.get(\'a\'), Math.min(last.get(\'b\'), last.get(\'c\')));\n        }\n        \n        return res;\n    }\n}\n\n```\n```java []\nclass Solution {\n    \n    public int numberOfSubstrings(String s) {\n        int last[] = {-1, -1, -1}, res = 0, n = s.length();\n        for (int i = 0; i < n; ++i) {\n            last[s.charAt(i) - \'a\'] = i;\n            res += 1 + Math.min(last[0], Math.min(last[1], last[2]));\n        }\n        return res;\n    }\n}\n```
['Hash Table', 'String', 'Sliding Window', 'Java']