Longest Common Subsequence
Problem Statement
Given two strings
XYA Longest Common Subsequence is a sequence that appears in the same order in both
XYXYXYRules and Constraints
- The input strings and
Xare of arbitrary length and comprise alphanumeric characters only.Y - 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
mare the lengths ofnandX, 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.Y - Space complexity: O(m*n) to store the dynamic programming table.
- Time complexity: O(m*n) where
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,
XYExample
Input: {"input_data":[1,2,3]} Output: [1,2,3]
CompaniesGoogleMetaAmazon
JavaScript
Login to write code
Solve problems, verify your skills, and earn XP.