첫째줄에 N과 X가 주어짐.
둘째줄에 정수 N개로 이루어진 수열 A가 주어짐.
이때 수열A에 있는 숫자중에 X보다 작은 정수를 출력해야함.
예제 입력:
10 5
1 10 4 9 2 3 8 5 7 6
예제 출력:
1 4 2 3
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
let array = [];
const onInput = (input) => array.push(input);
const onClose = () => {
let [N, X] = array[0].split(' ');
let S = array[1].split(' ');
// console.log(S); //--> [ '1', '10', '4', '9', '2', '3', '8', '5', '7', '6' ]
let answer = '';
for (let i = 0; i < N; i++) {
if(Number(S[i]) < X) { // S[i]를 숫자로 바꿔줘야 X와 비교가 됨.
answer += S[i] + ' ';
}
}
console.log(answer);
process.exit();
}
rl.on('line', onInput)
.on('close', onClose);