Longest Common Subsequence
Problem Statement
Given two strings
and
, find the length of their
Longest Common Subsequence (LCS).
A Longest Common Subsequence is a sequence that appears in the same order in both
and
and has no common elements other than those from
and
. This means that the sequence should not be a subset of another string within
or
.
Rules and Constraints
- The input strings and are of arbitrary length and comprise alphanumeric characters only.
- The output is an integer representing the length of the Longest Common Subsequence.
- Time and space complexity constraints:
- Time complexity: O(m*n) where and are the lengths of and , respectively. This is because we will be using a 2D array to store the dynamic programming table, and we need to iterate over each character in both strings once.
- Space complexity: O(m*n) to store the dynamic programming table.
Requirements
Your solution should be written in a programming language supported by our platform. It should be a standalone function that takes two string parameters,
and
, and returns an integer representing the length of the Longest Common Subsequence.
Example
Input: {"input_data":[1,2,3]}
Output: [1,2,3]