January 09, 2025 |13.7K Views

    Check whether a given string is an interleaving of two other given strings

      Share   Like
    Description
    Discussion

    Given three strings A, B and C. Write a function that checks whether C is an interleaving of A and B. C is said to be interleaving A and B, if it contains all and only characters of A and B and order of all characters in individual strings is preserved.

    Example:

    Input: strings: "XXXXZY", "XXY", "XXZ"
    Output: XXXXZY is interleaved of XXY and XXZ
    The string XXXXZY can be made by 
    interleaving XXY and XXZ
    String:    XXXXZY
    String 1:    XX Y
    String 2:  XX  Z


    Check whether a given string is an interleaving of two other given strings: https://www.geeksforgeeks.org/find-if-a-string-is-interleaved-of-two-other-strings-dp-33/