작성
·
186
0
function solution(str) {
let answer;
let stack = [];
if(str.length % 2 === 1) return "NO";
for(let i = 0; i < str.length; i++) {
if(str[i] === '(') stack.push(str[i]);
else stack.pop();
}
if(stack.length === 0) answer = "Yes";
else answer = "NO";
return answer;
}
let a=")()(";
console.log(solution(a));