You are viewing a single comment's thread. Return to all comments →
cpp with hashmap // unordered_map :
string happyLadybugs(string b) { unordered_map<char, int> charInt; for (int s = 0; s < b.length(); s++) { if (charInt.find(b[s]) == charInt.end()) { charInt[b[s]] = 1; } else { charInt[b[s]]++; } } for (auto it : charInt) { if ((it.second < 2) && it.first != '_') { return "NO"; } } if (b.find('_') == std::string::npos && charInt.size() > 1) { for (int i = 0; i < b.length() - 1; ++i) { if ((i > 0 && b[i] == b[i - 1]) || (i < b.length() - 1 && b[i] == b[i + 1])) { continue; } else { return "NO"; } } } return "YES"; }
Seems like cookies are disabled on this browser, please enable them to open this website
Happy Ladybugs
You are viewing a single comment's thread. Return to all comments →
cpp with hashmap // unordered_map :