[PS 백준 - 1.7] 10988번: 펠린드롬인지 확인하기

PongkiJoa·2021년 6월 29일
0

PS Diary - 백준

목록 보기
8/54
post-thumbnail

문제 정보

백준 10988번 - 바로가기

  • 난이도: 브론즈 1
  • 알고리즘: 문자열

코멘트

큐를 이용하여 풀어보았다.


소스 코드

#include <iostream>
#include <deque>
#include <algorithm>

using namespace std;

int main() {
	cin.tie(NULL);
	cout.tie(NULL);
	std::ios::sync_with_stdio(false);

	string str;
	deque<char> q;
	cin >> str;
	for (int i = 0; i < str.length(); i++) {
		q.push_front(str[i]);
	}

	bool flag = false;
	while (q.size() > 1) {
		if (q.front() != q.back()) {
			flag = true;
			break;
		}
		else {
			q.pop_front();
			q.pop_back();
		}

	}

	if (flag) cout << 0;
	else cout << 1;
}
profile
컴공 20학번

0개의 댓글

관련 채용 정보

Powered by GraphCDN, the GraphQL CDN