#169. 列表非负整数筛选

    ID: 169 Type: Default 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>codingbatFunctional-2gesp1循环结构条件结构

列表非负整数筛选

Filter Non-Negative Integers

Background

Congcong is organizing his collection of numbers. He has a list of integers but is only interested in those that are non-negative.

Problem Description

Given a list of integers, return a new list containing only the non-negative integers (i.e., integers greater than or equal to 00) from the original list, omitting any integers that are less than 00.

Input Format

The input is given from standard input in the following format.

The input consists of a single line representing a list of integers. The list starts and ends with square brackets [ and ], and the integers inside are separated by spaces.

Output Format

The output is printed to standard output in the following format.

The output consists of a single line representing the filtered list of integers. The list starts and ends with square brackets [ and ], and the integers inside are separated by a comma and a space , . If the list is empty, output [].

Sample

[1 -2]
[1]
[-3 -3 3 3]
[3, 3]
[-1 -1 -1]
[]

Sample Explanation

For the first sample, the input list is [1 -2]. Here, 11 is a non-negative integer, while 2-2 is a negative integer. Therefore, the new filtered list is [1].

Constraints

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