본문 바로가기
Coding Test/Programmers

[Programmers] (2017 팁스타운) Lv 2. 짝지어 제거하기

by song.ift 2024. 10. 15.

https://school.programmers.co.kr/learn/courses/30/lessons/12973

 

프로그래머스

코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.

programmers.co.kr

 

#include <iostream>
#include<string>
#include <stack>
#include <algorithm>
using namespace std;

int solution(string s)
{
    //24.10.15
    stack<char> st;
    
    for_each(s.begin(), s.end(), [&](const auto& ch) {
        (st.empty() || st.top() != ch) ? st.push(ch) : st.pop();
    });
    return st.empty();
}

GitHub : https://github.com/developeSHG/Algorithm-Baekjoon_Programmers/commit/bc839d7b6245849d6d339d95ddbad0b6420e41a0#diff-80bfd44c157f881795bbffd0a6fb879ef08e37f1b4c7da3fa72ce22b19d6d6a4

 

[level 2] Title: 짝지어 제거하기, Time: 5.78 ms, Memory: 6.39 MB -BaekjoonHub · developeSHG/Algorithm-Baekjoon_Programme

developeSHG committed Oct 14, 2024

github.com

 

 

댓글