#308. 字符串交错合并

    ID: 308 Type: Default 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>codingbatString-2gesp3字符串模拟

字符串交错合并

Interleaving Strings

Background

During a programming practice session, Congcong encountered an interesting string processing problem. He needed to merge two given strings in a specific way.

Problem Description

Given two strings, aa and bb, create a new string. The new string is formed by interleaving the first character of aa, the first character of bb, the second character of aa, the second character of bb, and so on. Any leftover characters from the longer string are appended to the end of the result.

Input Format

Input is given from standard input in the following format.

A single line containing two strings aa and bb, separated by a space.

Output Format

Output is printed to standard output in the following format.

A new string formed by interleaving aa and bb.

Sample

abc xyz
axbycz
Hi There
HTihere
xxxx There
xTxhxexre

Sample Explanation

For sample 1, string aa is abc and string bb is xyz. Interleaving them results in axbycz. For sample 2, string aa is Hi and string bb is There. First, interleave H and T, then i and h, resulting in HTih. String aa is exhausted. Append the remaining ere from string bb to the end, finally getting HTihere. For sample 3, string aa is xxxx and string bb is There. First, interleave x and T, x and h, x and e, x and r, resulting in xTxhxexr. String bb is exhausted. Append the remaining x from string aa to the end, finally getting xTxhxexre.

Constraints

Time limit: 11 second. Memory limit: 10241024 KiB for each test case.