PROBLEM LINK:Author and Editorialist : Vishal Sharma DIFFICULTY:EasyMedium PREREQUISITES:DP EXPLANATION:Brute force approach Time complexity  O( str1 * str2 ) First, check whether all characters in str2 are also present in str1. If not, it is impossible to obtain str2 using str1. Then, write a nested loop to search each character of str2 in str1. Dynamic programming solution time complexity – O( s1*26 + s2) First create a matrix l[s1+1][256] if (s1[i] == j) l[i][j] = i; else if (i + 1 < n1) l[i][j] = l[i + 1][j]; SOLUTION
This question is marked "community wiki".
asked 16 Oct '15, 19:36
