You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Given two strings X and Y. The task is to find the length of the longest common substring.
Input:
First line of the input contains number of test cases T. Each test case consist of three lines, first of which contains 2 space separated integers N and M denoting the size of string X and Y strings respectively. The next two lines contains the string X and Y.
Output:
For each test case print the length of longest common substring of the two strings .
Constraints:
1 <= T <= 200
1 <= N, M <= 100
Example:
Input:
2
6 6
ABCDGH
ACDGHR
3 2
ABC
AC
Output:
4
1
Example:
Testcase 1: CDGH is the longest substring present in both of the strings.
*/
#include<bits/stdc++.h>
using namespace std;
int LCSubstring(string x, string y, int m, int n){