C++ O(N^3) Solution
Runtime: 4 ms, faster than 88.92% of C++ online submissions for Count Substrings That Differ by One Character.\nMemory Usage: 6.7 MB, less than 5.49% of C++ onl
Runtime: 4 ms, faster than 88.92% of C++ online submissions for Count Substrings That Differ by One Character.\nMemory Usage: 6.7 MB, less than 5.49% of C++ online submissions for Count Substrings That Differ by One Character.\n\n\nTake substring from every pair of points of 0 to s.length and 0 to t.length and count the number of substrings\nwhich has exactly 1 mismatch.\n\n```\nclass Solution {\npublic:\n    \n    int countSubstrings(string s, string t) {\n        \n        // count of substring differ in 1 charecter only \n        int count = 0;\n        \n        // take substring starting from every pair of points between 0 to s.length and 0 to t.length => O(N^2)\n        // count the number of substring which has exactly 1 mismatch => O(N)  \n        for(int i=0;i<s.length();i++)\n        {\n            for(int j=0;j<t.length();j++)\n            {\n                int misMatch = 0;\n                \n                for(int k=0;i+k<s.length() && j+k<t.length();k++)\n                {\n                    if(s[i+k]!=t[j+k])misMatch++;\n                    \n                    if(misMatch>1) break;\n                    \n                    count+= misMatch;\n                }\n            }\n        }\n        \n        return count;\n    }\n};\n```
['String', 'C']