Try
[Programmers/C++] 짝지어 제거하기, 효율성1,2,3,4 오류 본문
출처
https://programmers.co.kr/learn/courses/30/lessons/12973#
소스
#include <iostream>
#include <string>
#include <queue>
using namespace std;
int solution(string s)
{
int answer = 0;
queue<char> q;
for(int i = 0; i < s.size(); i++){
q.push(s[i]);
}
queue<char> p;
int cnt = 1;
char value;
char compare;
while(!q.empty()){
if(cnt >= q.size()){
return 0;
}
value = q.front();
q.pop();
compare = q.front();
if(value == compare){
q.pop();
cnt = 1;
}
else{
q.push(value);
cnt++;
}
}
answer = 1;
return answer;
}
'Algorithm > Programmers' 카테고리의 다른 글
[Programmers/C++] 올바른 괄호 (0) | 2019.04.07 |
---|---|
[Programmers/C++] H-Index (0) | 2019.04.07 |
[Programmers/C++] 예상 대진표 (0) | 2019.04.04 |
[Programmers/Python] 폰켓몬 (0) | 2019.04.04 |
[Programmers/C++] 폰켓몬 (0) | 2019.04.04 |
Comments