{"id":"40b5214b-2900-413f-9211-d30f4659c9b9","name":"Longest Common Substring","description":"1. You are given two strings S1 and S2.\r\n2. You are required to print the length of the longest common substring of two strings.","inputFormat":"2 strings S1 and S2","outputFormat":"A number representing the length of longest common substring of two strings.","constraints":"1 < length of strings S1 and S2 <= 200","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n\tpublic static int solution(String s1, String s2){\r\n\t\t//write your code here\r\n\r\n\t\treturn 0;\r\n\t}\r\n\r\n\tpublic static void main(String[] args) {\r\n\t\tScanner scn = new Scanner(System.in);\r\n\t\tString s1 = scn.next();\r\n\t\tString s2 = scn.next();\r\n\t\tSystem.out.println(solution(s1,s2));\r\n\t}\r\n\r\n}"},"node":{"code":""},"ruby":{"code":""},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"abcdgh\r\nacdghr","sampleOutput":"4\r\n","questionVideo":"https://www.youtube.com/embed/NvmJBCn4eQI?end=673","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"5539a6e8-c8bf-4f04-805c-e43e9d20e72a","name":"Dynamic Programming For Intermediate","slug":"dynamic-programming-for-intermediate-408","type":0},{"id":"8e306240-5eea-4f3b-b213-b3591773b429","name":"Longest Common Substring","slug":"longest-common-substring","type":1}],"next":{"id":"0744c287-330f-4670-b904-07a2df5afc99","name":"Longest common substring MCQ","type":0,"slug":"longest-common-substring-mcq"},"prev":{"id":"4fdf91a7-e81e-4b02-9b36-021e58dbb956","name":"Regular Expression Matching","type":3,"slug":"regular-expression-matching"}}}

Longest Common Substring

1. You are given two strings S1 and S2. 2. You are required to print the length of the longest common substring of two strings.

{"id":"40b5214b-2900-413f-9211-d30f4659c9b9","name":"Longest Common Substring","description":"1. You are given two strings S1 and S2.\r\n2. You are required to print the length of the longest common substring of two strings.","inputFormat":"2 strings S1 and S2","outputFormat":"A number representing the length of longest common substring of two strings.","constraints":"1 < length of strings S1 and S2 <= 200","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n\tpublic static int solution(String s1, String s2){\r\n\t\t//write your code here\r\n\r\n\t\treturn 0;\r\n\t}\r\n\r\n\tpublic static void main(String[] args) {\r\n\t\tScanner scn = new Scanner(System.in);\r\n\t\tString s1 = scn.next();\r\n\t\tString s2 = scn.next();\r\n\t\tSystem.out.println(solution(s1,s2));\r\n\t}\r\n\r\n}"},"node":{"code":""},"ruby":{"code":""},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"abcdgh\r\nacdghr","sampleOutput":"4\r\n","questionVideo":"https://www.youtube.com/embed/NvmJBCn4eQI?end=673","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"5539a6e8-c8bf-4f04-805c-e43e9d20e72a","name":"Dynamic Programming For Intermediate","slug":"dynamic-programming-for-intermediate-408","type":0},{"id":"8e306240-5eea-4f3b-b213-b3591773b429","name":"Longest Common Substring","slug":"longest-common-substring","type":1}],"next":{"id":"0744c287-330f-4670-b904-07a2df5afc99","name":"Longest common substring MCQ","type":0,"slug":"longest-common-substring-mcq"},"prev":{"id":"4fdf91a7-e81e-4b02-9b36-021e58dbb956","name":"Regular Expression Matching","type":3,"slug":"regular-expression-matching"}}}
plane

Editor


Loading...

Longest Common Substring

easy

1. You are given two strings S1 and S2. 2. You are required to print the length of the longest common substring of two strings.

Constraints

1 < length of strings S1 and S2 <= 200

Format

Input

2 strings S1 and S2

Output

A number representing the length of longest common substring of two strings.

Example

Sample Input

abcdgh acdghr

Sample Output

4

Question Video

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode