iJoom
Denovation Dev information
iJoom
전체 방문자
오늘
어제
  • 분류 전체보기 (29)
    • Swift information (5)
    • Deep Dive iOS (10)
    • Books (1)
    • Conference (1)
    • 알고리즘 풀이 (10)
    • 알고리즘 개념 및 Tool C++ (2)

블로그 메뉴

  • 홈
  • 태그
  • 방명록

공지사항

인기 글

태그

  • 순열
  • iOS Structure
  • struct
  • 완전탐색
  • Core Services
  • Cocoa Touch
  • sceneWillResignActive
  • permuation
  • SWIFT
  • C++
  • decdoingError
  • 자료형에러
  • sidetable
  • unowned
  • Strong
  • Swift Concurrency
  • 알고리즘
  • 백준
  • ValuesCapturing
  • 문자열압축
  • EscapingClosure
  • MergeConflicts
  • ios
  • Core OS
  • bj4344
  • applicationWillResignActive
  • ARC
  • 캡처리스트
  • Weak
  • 문자열

최근 댓글

최근 글

티스토리

hELLO · Designed By 정상우.
iJoom

Denovation Dev information

알고리즘 풀이

[백준] 1316 그룹 단어 체커 (C++)

2021. 3. 12. 22:37
#include<bits/stdc++.h>

using namespace std;


int grword;

int main() {

	int n;
	
	cin >> n;

	for (int i = 0; i < n; i++) {
		int alpha[26] = { 0, };
		string word;
		cin >> word;
		int flag = 0;
		for (int k = 0; k < word.size(); k++) {
			alpha[(int)word[k] - 97]++;
			
			//앞뒤글자가 다를때, 앞에 알파벳이 나왔던 알파벳인지 검사
			if (alpha[(int)word[k] - 97] > 1 && word[k] != word[k - 1]) {
				flag = 1;
				break;
			}
		}
		if (flag == 0) {
			grword++;
		}
	}


	cout << grword;

	return 0;
}

문자열 , 구현 문제

 

앞뒤 다른 알파벳이 나왔을때 , 앞에 나왔던 알파벳이 나왔는지를 alpha[26] 배열을 통해 검사하면 된다.

alpha 배열은 여태까지 나왔던 알파뱃을 index화해서 개수를 count 해하여 저장해놓은 배열

'알고리즘 풀이' 카테고리의 다른 글

[백준] 16945 매직스퀘어로 변경하기 (순열을 이용한 풀이)  (0) 2021.05.24
[백준] 1120 문자열 - 완전탐색  (0) 2021.05.12
[백준] 일곱난쟁이 완전탐색  (0) 2021.05.11
[백준] 크로아티아 알파벳  (0) 2021.03.12
bj4344 C++ 풀이  (0) 2021.03.10
    '알고리즘 풀이' 카테고리의 다른 글
    • [백준] 1120 문자열 - 완전탐색
    • [백준] 일곱난쟁이 완전탐색
    • [백준] 크로아티아 알파벳
    • bj4344 C++ 풀이
    iJoom
    iJoom

    티스토리툴바