LONGEST COMMON SUBSTRING

Given 2 strings of lowercase alphabets A and B of size N and M respectively.

Return the length of longest common substring in A and B.



Input Format

The first argument given is the string A.
The second argument given is the string B.

Output Format

Return the length of longest common substring in A and B.

Constraints

1 <= N, M <= 1000

For Example

Input 1:
    A = "interviewbit"
    B = "intermission"
Output 1:
    5
Explaination 1:
    Longest commen substring in A and B is "inter"

Input 2:
    "interviewbit"
    "interstellarviewbit"
Output 2:
    8
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.
Start solving LONGEST COMMON SUBSTRING on Interview Code Editor
Sign Up
to access hints and editorial solutions for LONGEST COMMON SUBSTRING

Discussion


Loading...
Click here to start solving coding interview questions