Codeforces Round #835 (Div. 4) B. Atilla’s Favorite Problem
To solve the problem we need to find the character with the highest alphabetical order in our string, since Atilla will need at least that alphabet size and won’t need more. To do this iterate through the string and find the character with the highest alphabetical order. Output the maximum alphabetical order found. The solution can be done in O ( n ) O(n) O(n).
#include<bits/stdc++.h>
using namespace std;int main()
{int T=1;cin>>T;while(T--){int n;cin>>n;string s;cin>>s;cout<<*max_element(s.begin(),s.end())-'a'+1<<endl;}return 0;
}