function solution(s){
const stack = []
for (let i = 0; i < s.length; i++) {
if (s[i] === '(') {
stack.push('(')
} else {
if (stack[stack.length - 1] === '(') {
stack.pop()
} else {
stack.push(')')
}
}
}
if (stack.length > 0) {
return false
} else {
return true
}
}
=> 1차시도는 그냥 스택 써서 풀려고 하다가 틀림
))))(((()))) 경우를 True로 뱉는 경우 발생함. 2차 시도에서는 마지막 인덱싱이 (일 떄만 pop하는 구조로 변경하고 통과