알고리즘 (with. 백준 문제풀이)/Stack4 백준 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. Stack - 이론 Stack 1. 스택(Stack) 후입선출(Last-In-First-Out)의 특징을 가지는 기본적인 자료구조 중 하나. 2. 스택 사용법 with JavaScript 자바스크립트에서는 배열이 스택의 연산을 지원. pop()과 push()가 가능. 2023. 9. 15. 이전 1 다음