Python O(mn) solution DP
\nclass Solution:\n    def countSubstrings(self, s: str, t: str) -> int:\n        m = len(s)\n        n = len(t)\n        \n        match = [[0 for _ in range(n
```\nclass Solution:\n    def countSubstrings(self, s: str, t: str) -> int:\n        m = len(s)\n        n = len(t)\n        \n        match = [[0 for _ in range(n+1)] for _ in range(m + 1)]\n        matchOne = [[0 for _ in range(n+1)] for _ in range(m + 1)]\n        \n        match[0][0] = 0\n        \n        total = 0\n        \n        for i in range(1,m+1):\n            for j in range(1, n+1):\n                # print(i,j,s[i-1],t[j-1])\n                # print(match[i-1][j-1])\n                if s[i-1] == t[j-1]:\n                    match[i][j] = 1 + match[i-1][j-1]\n                    matchOne[i][j] = matchOne[i-1][j-1]\n                else:\n                    # print("Here")\n                    match[i][j] = 0\n                    matchOne[i][j] = 1 + match[i-1][j-1]\n                    \n                total += matchOne[i][j]\n             \n            \n        # print(match)\n        # print(matchOne)\n        return total\n```
[]