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) {
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].size()))
return false;
}
return true;
} 입력하세요
sort를 활용해서 정렬하면 사전 순으로 정렬 되기 때문에
다음꺼 까지만 판별하면 되기 때문에 쉽게 풀린다.
ex) 119 118 119932 정렬시 118 119 119932 로 정렬됨.