Python 3 - simple counting
From each character in string s, and character t, 2 cases may appear:\n\n1. If the current characters differ, go ahead and make sure the remaining characters ar
From each character in string s, and character t, 2 cases may appear:\n\n1. If the current characters differ, go ahead and make sure the remaining characters are equal. When enlarging the substring, increment answer by 1 each time.\n2. If the current characters are the same, go ahead and look for the first pair of characters that are different, and then go back to case 1.\n\n\n```python\nclass Solution:\n    def countSubstrings(self, s: str, t: str) -> int:\n        n1, n2 = len(s), len(t)\n        ans = 0\n\n        for i1, c1 in enumerate(s):\n            for i2, c2 in enumerate(t):\n                i, j = i1, i2\n\t\t\t\t# case 2\n                while i < n1 and j < n2 and s[i] == t[j]:\n                    i += 1\n                    j += 1\n\t\t\t\t# case 1\n                if i < n1 and j < n2 and s[i] != t[j]:\n                    i += 1\n                    j += 1\n                    ans += 1\n                    while i < n1 and j < n2 and s[i] == t[j]:\n                        i += 1\n                        j += 1\n                        ans += 1\n        return ans\n```
[]