오늘의 알고리즘
[C++]해시 전화번호 목록(프로그래머스 2레벨)
하늘하늘 .
2022. 2. 24. 16:04
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
bool solution(vector<string> phone_book)
{
sort(phone_book.begin(), phone_book.end());
for (int i = 0; i < phone_book.size(); ++i)
{
if (phone_book[i] == phone_book[i + 1].substr(0, phone_book[i].size()))
return false;
}
return true;
}
풀고나니까 해시 문제네...ㅎㅎ...