본문 바로가기

코딩테스트 문제풀이

[구름, javascript] 배열 합치기

const fs = require('fs');
const stdin = (process.platform === 'linux'
    ? fs.readFileSync('/dev/stdin').toString()
    : 
`5 4
2 3 6 7 8
1 8 9 11`).split('\n');
 
const input = (() => {
    let line = 0;
    return () => stdin[line++];
})();

function solution(A, B){
  let arrA = input().split(' ').map(v=>+v);
  let arrB = input().split(' ').map(v=>+v);
  console.log((arrA.concat(arrB)).sort((a, b) => a-b).join(' ')+' ')
}
let num = (input().split());
solution(...num)

 

구름은 표준 입출력 뿐 아니라 파일 입출력으로 해도 됩니다 !

개인적으로 이게 더 편하네요.