#20. 创建双倍长度数组
创建双倍长度数组
Create Double Length Array
Background
Congcong is currently learning about array operations. He encountered an interesting problem that requires creating a new array based on an existing one.
Problem Description
Given an integer array, return a new array with double the length where its last element is the same as the original array, and all the other elements are . The original array will be length or more. Note: by default, a new integer array contains all 's.
Input Format
Input is given from standard input in the following format.
An integer array, with elements separated by spaces.
Output Format
Output is printed to standard output in the following format.
A new integer array, with elements separated by commas and spaces.
Sample
[4 5 6]
[0, 0, 0, 0, 0, 6]
[1 2]
[0, 0, 0, 2]
[3]
[0, 3]
Sample Explanation
For the first sample, the original array is [4 5 6], with a length of . The new array's length should be . The last element of the new array should be the same as the last element of the original array, which is , and all other elements should be . Thus, the new array is [0, 0, 0, 0, 0, 6].
Constraints
Time limit: second. Memory limit: KiB for each test case.