{"id":"4413fd02-f917-47e9-99d9-b4b57d53bf11","name":"Longest Common Subsequence","description":"1. You are given a string str1.\r\n2. You are given another string str2.\r\n3. You are required to print the length of longest common subsequence of two strings.","inputFormat":"A string str1\r\nA string str2","outputFormat":"A number representing the length of longest common subsequence of two strings.","constraints":"0 <= str1.length <= 10\r\n0 <= str2.length <= 10","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static void main(String[] args) throws Exception {\r\n\r\n }\r\n\r\n}"},"node":{"code":""},"ruby":{"code":""},"python":{"code":""}},"points":10,"difficulty":"medium","sampleInput":"abcd\r\naebd","sampleOutput":"3","questionVideo":"https://www.youtube.com/embed/0Ql40Llp09E?end=222","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":"f90da01a-c2ba-4d16-ae42-046722214bb4","name":"Longest Common Subsequence","slug":"longest-common-subsequence","type":1}],"next":{"id":"70099256-e13a-4657-8a2a-5fab8e5d7dcb","name":"Longest Palindromic Subsequences","type":1,"slug":"longest-palindromic-subsequences"},"prev":{"id":"07e300f9-853a-4cfc-9328-06475fa8cc6a","name":"Longest Bitonic Subsequence","type":1,"slug":"longest-bitonic-subsequence"}}}

Longest Common Subsequence

1. You are given a string str1. 2. You are given another string str2. 3. You are required to print the length of longest common subsequence of two strings.

{"id":"4413fd02-f917-47e9-99d9-b4b57d53bf11","name":"Longest Common Subsequence","description":"1. You are given a string str1.\r\n2. You are given another string str2.\r\n3. You are required to print the length of longest common subsequence of two strings.","inputFormat":"A string str1\r\nA string str2","outputFormat":"A number representing the length of longest common subsequence of two strings.","constraints":"0 <= str1.length <= 10\r\n0 <= str2.length <= 10","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static void main(String[] args) throws Exception {\r\n\r\n }\r\n\r\n}"},"node":{"code":""},"ruby":{"code":""},"python":{"code":""}},"points":10,"difficulty":"medium","sampleInput":"abcd\r\naebd","sampleOutput":"3","questionVideo":"https://www.youtube.com/embed/0Ql40Llp09E?end=222","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":"f90da01a-c2ba-4d16-ae42-046722214bb4","name":"Longest Common Subsequence","slug":"longest-common-subsequence","type":1}],"next":{"id":"70099256-e13a-4657-8a2a-5fab8e5d7dcb","name":"Longest Palindromic Subsequences","type":1,"slug":"longest-palindromic-subsequences"},"prev":{"id":"07e300f9-853a-4cfc-9328-06475fa8cc6a","name":"Longest Bitonic Subsequence","type":1,"slug":"longest-bitonic-subsequence"}}}
plane

Editor


Loading...

Longest Common Subsequence

medium

1. You are given a string str1. 2. You are given another string str2. 3. You are required to print the length of longest common subsequence of two strings.

Constraints

0 <= str1.length <= 10 0 <= str2.length <= 10

Format

Input

A string str1 A string str2

Output

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

Example

Sample Input

abcd aebd

Sample Output

3

Question Video

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode