Iterative interleaving of strings

The interleaving of two strings xx and yy is a string that contains all characters of xx and yy and preserves the relative order of the characters in both xx and yy. For example, the interleaving of abcabc and xyzxyz is axbyczaxbycz. 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 xx and yy.

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.

Problem information

Author: Gabriel Valiente

Generation: 2026-01-25T16:25:44.679Z

© Jutge.org, 2006–2026.
https://jutge.org