C++ || 100% FAST || O(N ^ 3)
```\nclass Solution {\npublic:\n    int countSubstrings(string s, string t) {\n         int m = s.size(), n = t.size(), ans = 0;\n        \n         for(int i=0
```\nclass Solution {\npublic:\n    int countSubstrings(string s, string t) {\n         int m = s.size(), n = t.size(), ans = 0;\n        \n         for(int i=0; i<m ; i++){\n             for(int j=0; j<n; j++){\n                 int left = 1, right = 1;\n                 if(s[i] == t[j]) continue;\n                 \n                 // to left\n                 \n                 \n       while(i - left >= 0 && j - left >= 0 && s[i - left] == t[j - left]) left++;\n                 \n                 // to right\n                \n        while(i + right < m && j + right < n && s[i + right] == t[j + right]) right++;                 \n                 ans += left * right;\n             }\n         }\n        \n        return ans;\n    }\n};
['C']