[JAVA] CONSTANT SPACE SOLUTION
class Solution {\n\n    public int countSubstrings(String s, String t) {\n        int ans = 0;\n        for(int i = 0; i<s.length(); i++){\n            for(int 
class Solution {\n\n    public int countSubstrings(String s, String t) {\n        int ans = 0;\n        for(int i = 0; i<s.length(); i++){\n            for(int j = 0; j<t.length(); j++){\n                int x = i;\n                int y = j;\n                int d = 0;\n                while(x<s.length() && y<t.length()){\n                    if(s.charAt(x)!=t.charAt(y))d++;\n                    if(d==1)ans++;\n                    if(d==2)break;\n                    x++;\n                    y++;\n                }\n            }\n        }\n        return ans;\n    }\n}
['Dynamic Programming', 'Java']