알고리즘/백준

    [boj 2193] 이친수

    [boj 2193] 이친수

    // 이친수 // dp[i][0] = dp[i-1][1]+dp[i-1][0] // dp[i][1] = dp[i-1][0] const filePath = process.platform === "linux" ? "/dev/stdin" : "input.txt"; const input = require('fs').readFileSync(filePath).toString().trim().split(/\s/); const N = input.shift(); const sol = (N) =>{ const dp = Array.from(Array(91), () => new Array(2).fill(0)); dp[1][1] = 1; dp[2][0] = 1; for(let i=3; i 0,1 1 -> 0 따라서 dp[i][0..

    [boj 10808] 알파벳 개수 -js

    // 알파벳 개수 const filePath = process.platform === "linux" ? "/dev/stdin" : "input.txt"; const input = require('fs').readFileSync(filePath).toString().trim().split(/\s/); const S = input.shift(); const sol = (S) =>{ const charCode_a = 'a'.charCodeAt(); const charCode_z = 'z'.charCodeAt(); const count_alphabet = new Array(charCode_z-charCode_a+1).fill(0); for (let i = 0; i < S.length; i++) { count_a..

    [boj 1935] 후위 표기식2 -js

    후위 표기식을 일단 검색하였다.. https://woongsios.tistory.com/288(참고) // 후위 표기식2 const filePath = process.platform === "linux" ? "/dev/stdin" : "input.txt"; const input = require('fs').readFileSync(filePath).toString().trim().split(/\s/); const N = Number(input.shift()); const expression = input.shift(); const numArr = input.map(Number); const sol = (N,expression,numArr) =>{ const alphabetObj = {}; const stk..

    [boj 17299] 오등큰수 - js

    // 오등큰수 const filePath = process.platform === "linux" ? "/dev/stdin" : "input.txt"; const input = require('fs').readFileSync(filePath).toString().trim().split(/\s/).map(Number); const size_A = input.shift(); const element_A = input; const sol = (size_A,element_A) =>{ const result = new Array(size_A).fill(-1); const countArr = element_A.map(item => element_A.filter(item2=>item2 === item).length);..

    [boj 17298] 오큰수 - js

    // 오큰수 const filePath = process.platform === "linux" ? "/dev/stdin" : "input.txt"; const input = require('fs').readFileSync(filePath).toString().trim().split(/\s/).map(Number); const size_A = input.shift(); const element_A = input; const sol = (size_A,element_A) =>{ const result = new Array(size_A).fill(-1); const stack =[]; for(let i =0; i 0 && element_A[stack[stack.length-1]] < element_A[i]){ ..