Advertisement
MohamedAbdel3al

B. Two-gram

Sep 18th, 2021
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std ;
  4. #define sz(s) int(s.size())
  5. typedef long long ll ;
  6. #define all(v) v.begin() , v.end()
  7. #define imax INT_MAX
  8. #define imin INT_MIN
  9.  
  10. void ABDEL3AL () {
  11. ios_base::sync_with_stdio(false); cin.tie(nullptr) , cout.tie(nullptr) ;
  12. #ifndef ONLINE_JUDGE
  13. freopen("input.txt" , "r" , stdin) , freopen("output.txt" , "w" , stdout) ;
  14. #endif
  15. }
  16.  
  17. int main() {
  18. ABDEL3AL() ;
  19. int n ; cin >> n ;
  20. string s ; cin >> s ;
  21. map <string , int> mp ;
  22. for (int i = 0; i < sz(s) - 1; i++)
  23. mp[s.substr(i , 2)]++ ;
  24.  
  25. int Max = imin ;
  26. string ans ;
  27.  
  28. for (auto& i : mp)
  29. if (i.second > Max) ans = i.first ;
  30. cout << ans ;
  31. return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement