You are viewing a single comment's thread. Return to all comments →
C++:
int gemstones(std::vector<std::string> arr) { std::string biggerString{}; std::unordered_set<char> set; for (std::string &s : arr) { if (biggerString.size() < s.size()) { biggerString = s; } } int numberOfGemStones{0}; for (int i{}; i < biggerString.size(); i++) { char c{biggerString[i]}; int counter{0}; bool isCheckNeedsToBeDone{set.insert(c).second}; if (isCheckNeedsToBeDone) { for (std::string& s : arr) { if (std::string::npos != s.find(c)) { counter++; } } if (counter == arr.size()) { numberOfGemStones++; } } } return numberOfGemStones; }
Seems like cookies are disabled on this browser, please enable them to open this website
Gemstones
You are viewing a single comment's thread. Return to all comments →
C++: