C++ Solution (with explanation)
\nclass Solution {\npublic:\n    int countSubstrings(string s, string t) {\n        //here in this que the difference between characters should not be 1 like a-
```\nclass Solution {\npublic:\n    int countSubstrings(string s, string t) {\n        //here in this que the difference between characters should not be 1 like a->b or b->c\n        //instead the diff between the substring characters should differ by one like\n        //appl & appe here l&e are different that is the diff we need to find out(i.e diff=1 and not >1), then increment the ans by one\n        //if that diff is 2 break from the loop like for ex:- abc and bbe here (a,b) & (c,e) are diff in this \n        //substring.\n        //For all possible substring in s we need to check for all substring in t\n        \n        \n        int ans=0;\n        for(int i=0; i<s.length(); i++)\n        {\n        \tfor(int j=0; j<t.length(); j++)\n        \t{\n        \t\t//here x&y are used to form substring of s&t \n        \t\tint x=i, y=j, diff=0;\n        \t\twhile(x<s.size() && y<t.size())\n        \t\t{\n        \t\t\tif(s[x]!=t[y]) diff++;\n        \t\t\tif(diff==1) ans++;\n        \t\t\tif(diff==2) break;\n        \t\t\tx++;\n        \t\t\ty++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n        return ans;\n    }\n};\n```
[]