fork download
  1. #include <set>
  2. #include <string>
  3.  
  4. std::set<char> findRepeatedChars(const std::string& text) {
  5. std::set<char> seen;
  6. std::set<char> repeated;
  7.  
  8. for (size_t i = 0; i < text.size(); ++i) {
  9. char ch = text[i];
  10. // If already seen, it's a repeated character
  11. if (seen.find(ch) != seen.end()) {
  12. repeated.insert(ch);
  13. } else {
  14. seen.insert(ch);
  15. }
  16. }
  17.  
  18. return repeated;
  19. }
  20. int main(void){
  21.  
  22. }
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
Standard output is empty