Python 3 (easy to understand; with detailed explanation and comments)
Because every pair of string must have only one mismatch, it is more efficient to start with mismatched characters. Once you find a pair of mismatched pair of c
Because every pair of string must have only one mismatch, it is more efficient to start with mismatched characters. Once you find a pair of mismatched pair of characters, poke both backward and forward to find the number of matchs before and after the mismatched pair (num_pre and num_post). The total number of substring pairs that include this particular mismatched pair can be then calculated by (num_pre + 1) * (num_post + 1). Please note that this formula automatically includes the occurrence of the stand alone mismatched pair. \n\n\n```\nclass Solution:\n    def countSubstrings(self, s: str, t: str) -> int:\n        n1, n2 = len(s), len(t)\n        count = 0\n        for i in range(0,n1):\n            for j in range(0,n2):\n                # Only start to count when two characters differ\n                if s[i] != t[j]:\n                    # Counter how many matches immediately preceding the pair\n                    p = 1\n                    pre, post = 0, 0\n                    while i-p >=0 and j-p >= 0:\n                        if s[i-p] == t[j-p]:\n                            pre += 1\n                            p += 1\n                        else:\n                            break\n                    # Counter how many matches immediately following the pair\n                    p = 1\n                    while i+p < n1 and j+p < n2:\n                        if s[i+p] == t[j+p]:\n                            post += 1\n                            p += 1\n                        else:\n                            break\n                    # The total count should be increased by all combinations caused by preceding and following matches\n                    count += (pre + 1) * (post + 1)\n        return count        \n```
[]