Problem Statement

Given two strings str1 and str2 of lengths m and n respectively (m≤n), find whether str1 is a subsequence of str2

Examples:

Input: str1 = "axy", str2 = "abcxjhy"
Output: true

Approach

If length of lcs(str1,str2) = length of str1 then return true else return false

Reference Video

https://www.youtube.com/watch?v=QVntmksK2es&list=PL_z_8CaSLPWekqhdCPmFohncHwz8TY2Go&index=32&ab_channel=AdityaVerma

Complexity Analysis

Time and Space Complexity of the above implementation is O(m*n)