class ColorfulBricks { public: int countLayouts(string B) { map<char, int> cnt; for (int i = 0; i < B.size(); ++i) { ++cnt[B[i]]; } if (3 <= cnt.size()) return 0; if (cnt.size() == 1) return 1; if (cnt.size() == 2) return 2; return -1; } };