Skip to content

Commit

Permalink
add (programmers - level2 1문제): js 풀이
Browse files Browse the repository at this point in the history
  • Loading branch information
padosum committed Jan 3, 2023
1 parent b466641 commit 7860629
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions programmers/level2/짝지어 제거하기.js
@@ -0,0 +1,14 @@
function solution(s) {
let stack = []

s.split('').forEach((item, idx) => {
const top = stack[stack.length - 1]
if (top === item) {
stack.pop()
} else {
stack.push(item)
}
})

return stack.length === 0 ? 1 : 0
}

0 comments on commit 7860629

Please sign in to comment.