Last active
September 25, 2015 22:34
-
-
Save zacbrac/77888bb9f7f9ab8fce47 to your computer and use it in GitHub Desktop.
Gets counts of recurring characters in given string.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <map> | |
std::map<char, int, std::less<char>> getRepeatedChars(std::string text) { | |
std::map<char, int, std::less<char>> counts; | |
for (int i = 0; i < 403; i++) { | |
counts[text[i]]++; | |
} | |
return counts; | |
} | |
int main(int argc, const char * argv[]) { | |
std::string text = "LY3IoH5HWSnp9-efCfOH3jqmoGaXdURF4YAKgIh2KotjHLyFbLBgXr0uzPu1-K0sEGUogoTduKF1_eklAVzOlEfziqIvqtlhZeJPF8H2ER0jLc25jPC8_AOPlAvTHKdA8BVPFPwu1Ldaul4IPBVWJSJc5fhTGJAjfSL2Rum-pW8VCSJwnB3LZR1ACVR0KN0HCv7hIKJ88TNUc4hHk5g4sstPxdeQqUIu7GjY1C8M3jl4EMo9yqHoo1Mj7Q4vxPWGUM_OhMR46s772EpqNXk62pldQomWovdvB2pYh_srTFYM0u5MMQd5Z1nUUCwA--QiQX5cJmSxw7U8lVo78K6Qm4oGirfFJVlYIzPClCNziLewhEXvaKv1KmDtnUi03lAXQMuHjQqfMzMLJibXrw"; | |
std::map<char, int, std::less<char>> something = getRepeatedChars(text); | |
std::cout << something['L']; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment