#100. 数组去特定元素并填充
数组去特定元素并填充
Array Remove 10s and Fill Zeros
Background
Dawei is organizing a list of numbers and wants to remove specific numbers while keeping the list tidy.
Problem Description
Return a version of the given array where all the 10's have been removed. The remaining elements should shift left towards the start of the array as needed, and the empty spaces at the end of the array should be 0. So yields . You may modify and return the given array or make a new array.
Input Format
Input is given from standard input in the following format.
An array of integers, represented as
[a_1 a_2 ... a_N].
Output Format
Output is printed to standard output in the following format.
The modified array, represented as
[b_1, b_2, ..., b_N].
Sample
[1 10 10 2]
[1, 2, 0, 0]
[10 2 10]
[2, 0, 0]
[1 99 10]
[1, 99, 0]
Sample Explanation
In the first sample, the 10s are removed, 1 and 2 shift left, and the remaining two positions are filled with 0s. In the second sample, the 10s are removed, 2 shifts left, and the remaining two positions are filled with 0s. In the third sample, the 10 is removed, 1 and 99 shift left, and the remaining position is filled with 0.
Constraints
The length of the array satisfies . Each element in the array satisfies . Time limit: 1s, Memory limit: 1024KiB for each test case.