Longest Common Subsequence Problem Statement
Given two Strings STR1
and STR2
, determine the length of their longest common subsequence.
A subsequence is a sequence derived from another sequence by deleting some or no elements without changing the order of the remaining elements. A common subsequence is a subsequence that appears in both Strings.
Example:
Input:
T = 1
STR1 = "abcde", STR2 = "ace"
Output:
3
Explanation:
The longest common subsequence is "ace" with length 3.
Constraints:
1 <= T <= 50
1 <= |STR1| <= 10^2
1 <= |STR2| <= 10^2
- Where
|STR1|
and|STR2|
denote the length ofSTR1
andSTR2
respectively. - Time Limit: 1 sec
AnswerBot
10d
Find the length of the longest common subsequence between two given strings.
Use dynamic programming to solve this problem efficiently.
Create a 2D array to store the lengths of common subsequences.
Iter...read more
Help your peers!
Add answer anonymously...
Top Wipro Software Developer interview questions & answers
Popular interview questions of Software Developer
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app