Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- using namespace std;
- int main() {
- int n;
- string s;
- cin >> n >> s;
- int max = 0;
- string ans = "";
- for (int i = 0; i < n; i += 2) {
- string tmp = s.substr(i, 2);
- int cnt = 0;
- for (int i = 0; i < n - 1; ++i) {
- string str = s.substr(i, 2);
- if (tmp == str) {
- ++cnt;
- }
- }
- if (cnt > max) {
- max = cnt;
- ans = tmp;
- }
- }
- cout << ans << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement