O(nm) ^^
The solution superimposes two strings in all possible ways (hence quadratic complexity) and accumulates in variable out the number of respective substrings that
The solution superimposes two strings in all possible ways (hence quadratic complexity) and accumulates in variable `out` the number of respective substrings that differ by on character. \n<br>\n\n![image](https://assets.leetcode.com/users/images/02321361-adc2-48fc-9872-6aaa427d47e0_1618927668.0751498.png)\n\n<br>\n\nWhen simultaniously traversing the two strings we keep track of lengths of "runs" (`l`) - the same consequetive characters in both strings. We also need the length of the previous run (`p`). When characters match we add `p` to `out`. If characters mismatch  we add `l` to `out` and set `p` to `l`. Take a look at the picture to convince yourself.\n\n![image](https://assets.leetcode.com/users/images/2112ee61-4738-4a7d-a0cb-76e070bcbf74_1618927256.2312179.png)\n\n```\n    int countSubstrings(string s, string t) \n    {   \n        int out{0};\n        for(auto i{0}; i<size(s); i++)          \n            for(auto j{i}, k{0}, p{0}, l{1}; k<size(t) and j<size(s); ++k, ++j, ++l)\n                out += s[j]!=t[k] ? p=exchange(l,0) : p;\n               \n        for(auto i{1}; i<size(t); i++)\n            for(auto j{i}, k{0}, p{0}, l{1}; k<size(s) and j<size(t); ++k, ++j, ++l)\n                out += t[j]!=s[k] ? p=exchange(l,0) : p;\n       return out;\n    }\n```
['C', 'C++']