Variable Sized Sliding Window Solution
Intuition: Find total of all substring and subtract it with total of unfit Substrings\n Describe your first thoughts on how to solve this problem. \n\n# Approac
# Intuition: Find total of all substring and subtract it with total of unfit Substrings\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach: Approached the Problem using Sliding Window\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: 0(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: 0(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```java []\nclass Solution {\n\n    int find(String str, int k){\n           \n        int freqArr[] = new int[26];\n        int unfitSubstring = 0;\n        int start = 0;\n\n        for(int end = 0 ; end < str.length() ; end++){\n\n            int asciiValue = str.charAt(end) - 97;\n            freqArr[asciiValue]++;\n\n            while(start <= end && freqArr[asciiValue] >= k) {\n                \n                int val = str.charAt(start) - 97;\n                freqArr[val]--;\n                start++;\n                \n            }\n\n            unfitSubstring += (end-start) + 1;\n\n        }\n\n        return unfitSubstring;\n\n    }\n\n    public int numberOfSubstrings(String s, int k) {\n        \n        int length = s.length();\n        int totalSubstrings = length * (length + 1) / 2;\n\n        return totalSubstrings - find(s, k);\n        \n    }\n}\n```
['Hash Table', 'Sliding Window', 'Java']