C++ | Faster than 100% | 2 pointers | Easy Solution
\nclass Solution {\npublic:\n    int countSubstrings(string s, string t) {\n        int n = s.size(), m = t.size(), ans = 0;\n        for(int i = 0; i < n; i++)
```\nclass Solution {\npublic:\n    int countSubstrings(string s, string t) {\n        int n = s.size(), m = t.size(), ans = 0;\n        for(int i = 0; i < n; i++){\n            for(int j = 0; j < m; j++){\n                if(s[i] != t[j]){\n                    int cnt1 = 0, cnt2 = 0;\n                    int ips = i - 1, ipt = j - 1, ifs = i + 1, ift = j + 1;\n                    while(ips >= 0 && ipt >= 0 && s[ips] == t[ipt]){\n                        cnt1++, ips--, ipt--;\n                    }\n                    while(ifs < n && ift < m && s[ifs] == t[ift]){\n                        cnt2++, ifs++, ift++;\n                    }\n                    ans += cnt1 * cnt2 + cnt1 + cnt2 + 1;\n                }\n            }\n        }\n        return ans;\n    }\n};\n```
['Two Pointers', 'C']