HomeAboutMeBlogGuest
© 2025 Sejin Cha. All rights reserved.
Built with Next.js, deployed on Vercel
📝
프론트엔드 스쿨 교안(1기)
/
📝
(코테준비) 자료구조 및 알고리즘
/
✌
JS 100제 - 2권
/
🔥
문제83
/
✔️
답안
✔️

답안

function math(e){ const m = { ')':'(', '}':'{', }; let stack = []; for (let i=0; i<e.length; i++){ if (e[i].includes('(') || e[i].includes('{')){ stack.push(e[i]); } else if (m[e[i]]){ if (stack.length === 0){ return false; } else{ let t = m[e[i]]; if (t != stack.pop()){ return false; } } } } return stack.length === 0; } while (1){ const order = prompt('데이터 입력(1), 프로그램 종료(2)'); if (order === '1'){ const ex = prompt('데이터를 입력하세요').split(''); console.log(math(ex)); } else{ break; } }