JavaScript Solution - Brute Force
\nvar countSubstrings = function(s, t) {\n    const count1 = countAllSubstr(s);\n    const count2 = countAllSubstr(t);\n    \n    let res = 0;\n    \n    for (c
```\nvar countSubstrings = function(s, t) {\n    const count1 = countAllSubstr(s);\n    const count2 = countAllSubstr(t);\n    \n    let res = 0;\n    \n    for (const [substr1, freq1] of count1) {\n       for (const [substr2, freq2] of count2) {\n           \n           if (differByOneChar(substr1, substr2)) {\n               res += freq1 * freq2;\n           }\n       }\n    }\n    \n    return res;\n    \n    \n    function countAllSubstr(str) {\n        const n = str.length;\n        const count = new Map();\n        \n        for (let i = 0; i < n; i++) {\n            let substr = ""; \n            for (let j = i; j < n; j++) {\n                substr += str.charAt(j);\n            \n                if (!count.has(substr)) count.set(substr, 0);\n                count.set(substr, count.get(substr) + 1);\n            }\n        }\n        \n        return count;\n    }\n    \n    function differByOneChar(str1, str2) {\n        if (str1.length != str2.length) return false;\n        \n        const n = str1.length;\n        \n        let missed = 0;\n        \n        for (let i = 0; i < n; i++) {\n            const char1 = str1.charAt(i);\n            const char2 = str2.charAt(i);\n            \n            if (char1 != char2) missed++;\n            \n            if (missed > 1) return false;\n        }\n        \n        return missed === 1;\n    }\n    \n}; \n```
['JavaScript']