#189. 数组筛选:寻找指定数量的Endy数

    ID: 189 Type: Default 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>codingbatAp-1gesp1条件结构一维数组

数组筛选:寻找指定数量的Endy数

Find Endy Numbers

Background

Dawei is currently studying a special type of number. He calls these numbers "Endy numbers".

Problem Description

We define a positive integer nn as an "Endy number" if it is in the range 00 to 1010 (inclusive), or in the range 9090 to 100100 (inclusive). Given an array of positive integers, return a new array of length count containing the first count Endy numbers from the original array. Decompose the logic for testing if a number is Endy into a separate method isEndy(int n). The original array is guaranteed to contain at least count Endy numbers.

Input Format

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

The first line contains an array of integers, separated by spaces. The second line contains an integer count.

Output Format

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

An array of integers, containing the first count Endy numbers, with elements separated by commas and spaces, enclosed in square brackets [].

Sample

[9 11 90 22 6] 2
[9, 90]
[9 11 90 22 6] 3
[9, 90, 6]
[12 1 1 13 0 20] 2
[1, 1]

Sample Explanation

For the first sample input [9 11 90 22 6] 2: The Endy numbers in the array are 99 (in range 0..100..10), 9090 (in range 90..10090..100), and 66 (in range 0..100..10). We need the first 22 Endy numbers, so the output is [9, 90].

Constraints

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