C++ 100% fast O(m*n)
same[i][j] represent the length of maximum substring ending at i in string t and j in string s.\ndiff[i][j] represent the length of maximum substring ending at 
same[i][j] represent the length of maximum substring ending at i in string t and j in string s.\ndiff[i][j] represent the length of maximum substring ending at i in string t and j in string s with only 1 element different.\nThe memory can be reduced by just using only 2 rows as we require only (i-1)th row for calculating ith row.\n\n\t\t\'\'\'      \n\t\tint n = s.length(), m = t.length();\n        vector<vector<int>> same(n+1,vector<int> (m+1,0));\n        vector<vector<int>> diff(n+1,vector<int> (m+1,0));\n        int ans = 0;\n        for(int i =1;i<=n;i++)\n        {\n            for(int j = 1;j<=m;j++)\n            {\n                if(s[i-1]==t[j-1])\n                {\n                    same[i][j] = 1+same[i-1][j-1];\n                    diff[i][j] = diff[i-1][j-1];\n                }\n                else\n                {\n                    same[i][j] = 0;\n                    diff[i][j] = 1+same[i-1][j-1];\n                }\n                ans+=diff[i][j];\n            } \n        }\n        return ans;\n\t\t\'\'\'
['Dynamic Programming', 'C']