알고리즘/백준

    [boj 1475] 방 번호 - js

    // 방 번호 const filePath = process.platform === "linux" ? "/dev/stdin" : "input.txt"; const input = require("fs") .readFileSync(filePath) .toString() .trim() .split(/\n/); const sol = (input) => { const arr = input[0].split("").map(Number); const numObj = { 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0, 0: 0, }; arr.map((item) => item === 6 || item === 9 ? (numObj[6] += 1) : (numObj[item] +..

    [boj 9935] 폭발 문자열-js

    메모리 초과로 고민 좀 했다.. 내가 생각한 풀이 방법은 이렇다. 1. 폭발 문자열이 있다면 해당 문자열까지 배열에 삽입 2. 폭발 문자열 길이만큼 없앤 후 나머지 문자열 삽입 3. 반복 const filePath = process.platform === "linux" ? "/dev/stdin" : "input.txt"; const input = require('fs').readFileSync(filePath).toString().trim().split(/\n/); const str = input.shift(); const target_str = input.shift(); const CLEARTEXT = "FRULA"; const sol = (str, target_str) =>{ let arr = str..

    [boj 2455] 지능형 기차

    // 지능형 기차 const filePath = process.platform === "linux" ? "/dev/stdin" : "input.txt"; const input = require('fs').readFileSync(filePath).toString().trim().split(/\n/); const sol = (input) =>{ const arr = new Array(input.length); for(let i=0; i

    [boj 14889] 스타트와 링크

    // 스타트와 링크 const filePath = process.platform === "linux" ? "/dev/stdin" : "input.txt"; const input = require('fs').readFileSync(filePath).toString().trim().split(/\n/); const N = parseInt(input.shift()); const arr = input; const sol = (N, arr) =>{ const table = []; const visited = new Array(N).fill(false); for(let i=0; i{ let sum = 0; for(let i=0; i

    [boj 14888] 연산자 끼워넣기 -js

    // 연산자 끼워넣기 const filePath = process.platform === "linux" ? "/dev/stdin" : "input.txt"; const input = require('fs').readFileSync(filePath).toString().trim().split(/\n/); const N = parseInt(input[0]); const arr = input[1].split(' ').map(Number); const input_operator = input[2].split(' '); const sol = (N, arr, input_operator) =>{ const visited = new Array(N-1).fill(false); const vector = []; const..