Iterative interleaving of strings X46901


Statement
 

pdf   zip

html

The interleaving of two strings x and y is a string that contains all characters of x and y and preserves the relative order of the characters in both x and y. For example, the interleaving of abc and xyz is axbycz. Write a program that prints the interleaving of every given pair of strings.

Define and use an iterative function

interleaving(x,y)

that returns the interleaving of two strings x and y.

Interface

C++
string interleaving(string x, string y);
Python
interleaving(x, y) # returns str
 
interleaving(x: str, y: str) -> str

Input

The input consists of several pairs of strings.

Output

Print the interleaving of every given pair of strings.

Public test cases
  • Input

    abc xyz
    ab xyz
    abc xy
    

    Output

    axbycz
    axbyz
    axbyc
    
  • Information
    Author
    Gabriel Valiente
    Language
    English
    Official solutions
    C++ Python
    User solutions
    C++ Python