-
-
Save ilpropheta/e0b0b83b1ab66ee793a41ca1ebfd3a42 to your computer and use it in GitHub Desktop.
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
array<int, 26> freq{}; // letter counters | |
for (auto c : str) | |
++freq[c - 'a']; | |
cout << "The most frequent letter is: " << char('a' + distance(begin(freq), max_element(begin(freq), end(freq)))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment