C++ O(N^3) with explanation
See my latest update in repo LeetCode\n\n## Solution 1.\n\nIntuition: We can find each pair of s[i] != t[j]. Then try to extend both sides when s[i + t] == t[j 
See my latest update in repo [LeetCode](https://github.com/lzl124631x/LeetCode)\n\n## Solution 1.\n\nIntuition: We can find each pair of `s[i] != t[j]`. Then try to extend both sides when `s[i + t] == t[j + t]`. If we have `left` steps extended on the left side and `right` steps on the right side, we have `(left + 1) * (right + 1)` options for this `{ i, j }` case.\n\nExample:\n\n```\ns = xbabc\nt = ybbbc\n```\n\nFor `i = 2` and `j = 2`, we have `s[i] = a` and `t[j] = b` that doesn\'t match. Now look leftwards, we can extend left-side by 1 time due to `b`, and extend right-side by 2 times due to `bc`. So for this specific center `{ i = 2, j = 2 }`, we have `2 * 3 = 6` options.\n\n```cpp\n// OJ: https://leetcode.com/contest/biweekly-contest-38/problems/count-substrings-that-differ-by-one-character/\n// Author: github.com/lzl124631x\n// Time: O(N^3)\n// Space: O(1)\nclass Solution {\npublic:\n    int countSubstrings(string s, string t) {\n        int M = s.size(), N = t.size(), ans = 0;\n        for (int i = 0; i < M; ++i) {\n            for (int j = 0; j < N; ++j) {\n                if (s[i] == t[j]) continue;\n                int left = 1, right = 1;\n                while (i - left >= 0 && j - left >= 0 && s[i - left] == t[j - left]) ++left;\n                while (i + right < M && j + right < N && s[i + right] == t[j + right]) ++right;\n                ans += left * right;\n            }\n        }\n        return ans;\n    }\n};\n```
[]