BackeasyStrings

Determine Prolonged Concordance Solution

Problem Statement

Given two strings, find the length of the longest common subsequence (LCS) that appears in the same relative order in both strings, but not necessarily contiguously.

Example 1
Input
["abcdef","zbcdfg"]
Output
3

Explanation: The longest common subsequence is 'bcd' which has a length of 3 characters.

Example 2
Input
["abcdef","abcdef"]
Output
6

Explanation: The longest common subsequence is the string itself when both strings are identical, resulting in a length of 6.

Example 3
Input
["abcdefgh","xyz"]
Output
0

Explanation: Since there are no characters in common in the same relative order between 'abcdefgh' and 'xyz', the longest common subsequence has a length of 0.

Constraints

  • Both input strings will have lengths between 1 and 1000.
  • All characters in the strings are lowercase.
Live Compiler
Loading...
Test Cases & Output
🔒 Sign up to run your code

🚀 Practice this problem

Run code, get AI hints & track streak

Sign Up Free