findOccurencesOfWords

Run Settings
LanguageC++
Language Version
Run Command
#include <iostream> #include<sstream> #include<unordered_map> using namespace std; void findOccurencesOfWords(string s) { stringstream ss(s); string word; unordered_map<string, int> um; while (ss >> word) { um[word]++; } for(auto it : um) { cout << "(" << it.first << " : " << it.second << ")" << endl; } } // Driver program int main() { string str = "geeks for geeks geeks quiz practice qa for"; findOccurencesOfWords(str); //cout << str; return 0; }
Editor Settings
Theme
Key bindings
Full width
Lines