
😎풀이
stack
생성
- 최근 입력된 요소가 중복되는지 확인
2-1. 중복된다면 두 요소 모두 제거
2-2. 중복되지 않는다면 현재 요소 추가
- 요소들을 문자열로 합쳐 반환
function removeDuplicates(s: string): string {
const stack = []
for(const char of s) {
if(stack.at(-1) === char) stack.pop()
else stack.push(char)
}
return stack.join('')
};