C++ simple easy modified brute force with a trick, all test cases passed
\nclass Solution {\npublic:\n    \n    bool one_diff(string a, string b){\n        int d=0;\n        if(a.size()!=b.size())\n            return false;\n        
```\nclass Solution {\npublic:\n    \n    bool one_diff(string a, string b){\n        int d=0;\n        if(a.size()!=b.size())\n            return false;\n        if(a.size()==b.size()){\n            int n=a.size();\n            for(int i=0;i<n;i++){\n                if(a[i]!=b[i]){\n                    d++;\n                }\n                if(d>1)\n                    return false;\n            }\n        }\n        return d==1;\n    }\n    \n    int countSubstrings(string s, string t) {\n        int count=0;\n        int n=s.size(),m=t.size();\n        for(int i=0;i<n;i++){\n            for(int j=1;j<=n-i;j++){\n                for(int k=0;k<m;k++){\n                    int l=min(m-k,j);\n                    if(one_diff(s.substr(i,j),t.substr(k,l)))\n                        count++;\n                }\n            }\n        }\n        return count;\n    }\n};\n```
[]