|
|
back to boardSolution Posted by Hayk 12 Nov 2016 21:32 #include <iostream> #include <string> #include <vector> #include <algorithm> using namespace std; int main() { string word; cin >> word; vector<int> v(word.size(), 0); for(int i = 0; i < word.size(); ++i) { for(int j = 0; j < word.size(); ++j) { if(word[i] == word[j]) { v[i]++; } } } cout << word.substr(max_element(v.begin(), v.end()) - v.begin(), 1); } Re: Solution Why does it work? |
|
|