June 09, 2022 |740 Views

    Longest common subsequence with permutations allowed

      Share   Like
    Description
    Discussion

    Given two strings in lowercase, find the longest string whose permutations are subsequences of given two strings. The output longest string must be sorted.
    Examples: 
     

    Input  :  str1 = "pink", str2 = "kite"
    Output : "ik" 
    The string "ik" is the longest sorted string 
    whose one permutation "ik" is subsequence of
    "pink" and another permutation "ki" is 
    subsequence of "kite".

    Longest common subsequence with permutations allowed: https://www.geeksforgeeks.org/longest-common-subsequence-with-permutations-allowed/