https://school.programmers.co.kr/learn/courses/30/lessons/42577
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
bool solution(vector<string> phone_book) {
bool answer = true;
sort(phone_book.begin(),phone_book.end());
for (int i = 0; i < phone_book.size() - 1; ++i)
{
if (phone_book[i] == phone_book[i + 1].substr(0, phone_book[i].length())) return false;
}
return answer;
}
'Coding Test > Programmers' 카테고리의 다른 글
[Programmers] (2018 KAKAO BLIND RECRUITMENT) Lv 2. [3차] 압축 (0) | 2023.07.03 |
---|---|
[Programmers] (2022 KAKAO BLIND RECRUITMENT) Lv 2. k진수에서 소수 개수 구하기 (0) | 2023.06.26 |
[Programmers] (깊이/너비 우선 탐색(DFS/BFS)) Lv 2. 타겟 넘버 (0) | 2023.06.22 |
[Programmers] (완전탐색) Lv 2. 피로도 (0) | 2023.06.16 |
[Programmers] (2018 KAKAO BLIND RECRUITMENT) Lv 2. [1차] 뉴스 클러스터링 (0) | 2023.06.16 |
댓글