#189. 数组筛选:寻找指定数量的Endy数
数组筛选:寻找指定数量的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 as an "Endy number" if it is in the range to (inclusive), or in the range to (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
countEndy 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 (in range ), (in range ), and (in range ).
We need the first Endy numbers, so the output is [9, 90].
Constraints
Time limit: second, Memory limit: KiB for each test case.