인프런 커뮤니티 질문&답변
이건 잘못된 건가요?
작성
·
240
1
<!DOCTYPE html>
<html>
<head>
<title>후위식 연산(스택)</title>
</head>
<body>
<script>
function ASMD(a, b, c) {
if(c === '+') return a + b;
if(c === '-') return a - b;
if(c === '*') return a * b;
if(c === '/') return a / b;
}
function solution(s) {
let answer;
let stack = [];
for(let x of s) {
if(isNaN(x)) {
let b = Number(stack.pop());
let a = Number(stack.pop());
stack.push(ASMD(a, b, x));
} else stack.push(x);
}
return stack;
}
let postfix = "352+*9-";
console.log(solution(postfix));
</script>
</body>
</html>퀴즈
61%나 틀려요. 한번 도전해보세요!
스택 데이터 구조의 기본 원리는 무엇일까요?
먼저 들어온 요소가 먼저 나간다
가장 나중에 들어온 요소가 먼저 나간다
무작위 순서로 요소가 나간다
가장 먼저 들어온 요소가 가장 나중에 나간다






감사합니다😋