Dictionary Solution || Codeforces Round #786 (Div 3)

            

Dictionary Solution 

Codeforces Round #786 (Div 3)

Solution :

#include <bits/stdc++.h>
#define ll long long int
using namespace std;

int main()
{
    ll t = 1;
    cin >> t;
    while (t--)
    {
        string s;
        cin >> s;
        ll ans = 0;
        ans += 25 * (s[0] - 'a');
        ans += (s[1] - 'a');
        if (s[1] < s[0])
        {
            ans++;
        }
        cout << ans << "\n";
    }
}

Comments