Print Longest Common Subsequence

DP on Strings DSA practice problem on Onlearn.

Difficulty: hard.

Topics: How to Print the Longest Common Subsequence of Two Strings, Dynamic Programming, Tabulation, Subsequences, Strings, Time Complexity, Space Complexity, Backtracking, general programming, dynamic programming, time complexity analysis, string manipulation, 1D & 2D DP, DP Advanced Techniques.

Problem Statement Given two strings, S1 and S2, find and print their Longest Common Subsequence (LCS). Input Specification The input consists of two lines. The first line contains string S1. The second line contains string S2. Output Specification Print the Longest Common Subsequence string. Sample Test Cases Sample Input 1: Sample Output 1: