알고리즘

    [JS] 11728번 배열 합치기

    문제 https://www.acmicpc.net/problem/11728 11728번: 배열 합치기 첫째 줄에 배열 A의 크기 N, 배열 B의 크기 M이 주어진다. (1 ≤ N, M ≤ 1,000,000) 둘째 줄에는 배열 A의 내용이, 셋째 줄에는 배열 B의 내용이 주어진다. 배열에 들어있는 수는 절댓값이 109보다 작거 www.acmicpc.net 해결 방안 const input = require('fs').readFileSync('/dev/stdin').toString().split('\n'); let arr1 = input[1].split(' ').map(Number); let arr2 = input[2].split(' ').map(Number); const result = [].concat(ar..

    [JS] 1269번 대칭 차집합

    문제 https://www.acmicpc.net/problem/1269 1269번: 대칭 차집합 첫째 줄에 집합 A의 원소의 개수와 집합 B의 원소의 개수가 빈 칸을 사이에 두고 주어진다. 둘째 줄에는 집합 A의 모든 원소가, 셋째 줄에는 집합 B의 모든 원소가 빈 칸을 사이에 두고 각각 주어 www.acmicpc.net 해결 방안 const input = require('fs').readFileSync('/dev/stdin').toString().split('\n'); const arr1 = input[1].trim().split(' '); const arr2 = input[2].trim().split(' '); let setArr = new Set(arr1.concat(arr2)); let inter..

    [JS] 8595번 히든 넘버

    문제 https://www.acmicpc.net/problem/8595 8595번: 히든 넘버 첫째 줄에 단어의 길이 n (1 ≤ n ≤ 5,000,000)이 주어진다. 둘째 줄에는 단어가 주어진다. 단어는 알파벳 대/소문자와 숫자(0-9)로 이루어져 있다. www.acmicpc.net 해결 방안 - 처음 방법 const input = require('fs').readFileSync('/dev/stdin').toString().split('\n'); const count = parseInt(input[0]); const data = input[1].split(''); let result = 0; function solution() { let temp=''; for(let i=0;i

    [JS] 11816번 8진수, 10진수, 16진수

    문제 https://www.acmicpc.net/problem/11816 11816번: 8진수, 10진수, 16진수 첫째 줄에 X가 주어진다. X는 10진수로 바꿨을 때, 1,000,000보다 작거나 같은 자연수이다. 16진수인 경우 알파벳은 소문자로만 이루어져 있다. www.acmicpc.net 해결 방법 const input = require('fs').readFileSync('/dev/stdin').toString().split(''); function solution() { // 16진수인 경우 if (input[0]+input[1] === "0x"){ console.log(parseInt(input.slice(2,).join(''), 16)); } // 8진수인 경우 else if (input[..