class LongestSubstring {
public:
    int findLongest(string A, int n, string B, int m) {
       
       vector<vector<int>> dp(n+1,vector<int>(m+1,0));
        int maxx=0;
       for(int i=1;i<=n;i++)
       {
        for(int j=1;j<=m;j++)
        {
            if(A[i-1]==B[j-1])
            {
                dp[i][j]=dp[i-1][j-1]+1;
                maxx=max(maxx,dp[i][j]);
            }
        }
       }
       return maxx;
    }
};