#C4711. Interleaved Sequences
Interleaved Sequences
Interleaved Sequences
You are given two sequences of integers. Your task is to interleave the elements of the two sequences. That is, the first element of the output should be the first element of the first sequence, the second element should be the first element of the second sequence, the third element should be the second element of the first sequence, and so on. If one sequence is longer than the other, append the remaining elements of the longer sequence at the end.
Formally, given two sequences \(A = [a_1,a_2,\dots,a_n]\) and \(B = [b_1,b_2,\dots,b_m]\), define \(k = \min(n, m)\). The resulting sequence is \[ [a_1,b_1,a_2,b_2,\dots, a_k, b_k, a_{k+1},\dots,a_n, b_{k+1},\dots,b_m] \] If one of the sequences is empty, simply output the other sequence.
inputFormat
The input consists of two lines. The first line contains space-separated integers representing the first sequence. The second line contains space-separated integers representing the second sequence. If a sequence is empty, the corresponding line will be empty.
outputFormat
Output a single line containing the interleaved sequence. The numbers should be separated by a single space. If the resulting sequence is empty, output an empty line.
## sample1 3 5
2 4 6
1 2 3 4 5 6