Jishan's Log 11: Codeforces 112A solution

Codeforces 112A: Petya & Strings

What does the problem want?

Petya is given two strings. Petya now needs to make sure (regardless of case) the strings are of same length.

How to solve it?

The Algorithm:

1) Take 2 strings.
2) convert them to lower case
3) compare them 

The Code:

#include<bits/stdc++.h>
using namespace std;

#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int main()
{
    fastio;
    string s1cin >> s1;
    string s2cin >> s2;
    
    for_each(s1.begin(), s1.end(), [](char & c) {
        c = tolower(c);
    });
    for_each(s2.begin(), s2.end(), [](char & c) {
        c = tolower(c);
    });

    cout << s1.compare(s2<< "\n";
}

Comments

Popular posts from this blog

Jishan's Log 14: Codeforces 69A solution

Jishan's Log 12: Codeforces 236A solution

Jishan's Log 13: Codeforces 96A solution