알고리즘 (with. 백준 문제풀이)9 백준 1158번 [요세푸스 문제] // const n = 7 // const k = 3 const fs = require('fs'); const input = fs.readFileSync('/dev/stdin').toString().trim().split(); let [n, k] = input[0].split(' '); let queue = []; for(let i=1; i 2023. 9. 18. 백준 1935번 [후위표기식2] (오답) const fs = require('fs'); const input = fs.readFileSync("/dev/stdin").toString().trim().split("\n"); const [n, expression, ...num] = input; // const n = 5; // const expression = "ABC*+DE/-"; // const num = [1, 2, 3, 4, 5]; const arr = expression.split(""); const stack = []; for(let p of arr){ if('A' 2023. 9. 16. 백준 17413번 [단어 뒤집기 2] const fs = require('fs'); const input = fs.readFileSync("/dev/stdin").toString().trim(); // const input = "ef ghabc" const arr = input.split(""); let stack = []; let isInTag = false; // 태그 밖인지 안인지 구분 (공백 처리) let str = ""; for(let i=0; i 가 등장하면 태그 안에 있으므로 그대로 추가 str += stack.join(""); stack = []; } else if(arr[i] == " " && !isInTag){ str += stack.reverse().join("") + " "; stack = []; } // 주의할 구간 .. 2023. 9. 16. 백준 10799번 [쇠막대기] const fs = require('fs'); const input = fs.readFileSync("/dev/stdin").toString().trim(); const inputArr = input.split(""); let stack = [] // 쇠막대기 저장할 stack let cnt = 0 const len = inputArr.length; for(let i=0; i 2023. 9. 15. 이전 1 2 3 다음