#33. 按优先级合并数组

    ID: 33 Type: Default 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>codingbatArray-1gesp1条件结构顺序结构

按优先级合并数组

Array Merge

Background

Congcong has recently been learning about array operations and encountered an interesting small challenge. He needs to construct a new short array from two given arrays according to specific rules.

Problem Description

Given two integer arrays, aa and bb, return a new array of length 22. The new array should contain, as much as will fit, the elements from aa followed by the elements from bb. The arrays may be of any length, including 00, but it is guaranteed that there will be 22 or more elements available between the two arrays.

Input Format

Input is given from standard input in the following format.

A single line containing two integer arrays, aa and bb. Elements within each array are space-separated and enclosed in square brackets []. The two arrays are separated by a single space.

Output Format

Output is printed to standard output in the following format.

A single line containing an integer array of length 22. Elements within the array are separated by a comma and a space , , and enclosed in square brackets [].

Sample

[4 5] [1 2 3]
[4, 5]
[4] [1 2 3]
[4, 1]
[] [1 2]
[1, 2]

Sample Explanation

Sample 1: Array aa contains 22 elements [4, 5], which is enough to fill the result array. Thus, the result is [4, 5].

Sample 2: Array aa contains 11 element [4]. We take all elements from aa, then take the first element [1] from array bb to fill the remaining position. Thus, the result is [4, 1].

Sample 3: Array aa is empty. We take the first 22 elements [1, 2] from array bb to fill the result array. Thus, the result is [1, 2].

Constraints

Time limit: 11 second, Memory limit: 10241024 KiB.