#include <string> #include <vector> #include <algorithm> using namespace std ; bool solution ( vector < string > phone_book ) { sort ( phone_book . begin (), phone_book . end ()); vector < string >:: iterator it ; for ( it = phone_book . begin (); it != phone_book . end (); ++ it ) { vector < string >:: iterator it2 = it ; for ( ++ it2 ; it2 != phone_book . end (); ++ it2 ) { if (( * it2 ). find (( * it ). c_str (), 0 , ( * it ). size ()) != string :: npos ) { return false ; } } } return true ; }