You are viewing a single comment's thread. Return to all comments →
c++ solution
bool isless_m( string str1, string str2) { int N = min(str1.size(), str2.size()); for (int i = 0; i < N; ++i) { if (str1[i] < str2[i]) { return true; } else if (str1[i] > str2[i]) { return false; } } return false; } void noPrefix(vector<string> words) { if (words.size() == 1) { cout << "GOOD SET\n"; return; } set<string,decltype(&isless_m)> mp(&isless_m); for (int i = 0; i < words.size(); ++i) { auto it=mp.insert(words[i]); if (!it.second) { cout << "BAD SET\n"; cout << words[i]<<"\n"; return; } } cout << "GOOD SET\n"; }
Seems like cookies are disabled on this browser, please enable them to open this website
No Prefix Set
You are viewing a single comment's thread. Return to all comments →
c++ solution