Tuesday, November 14, 2017

Chef and Two Strings Codechef Problem Solution

https://www.codechef.com/problems/CHEFSTLT

In C++...........................

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

    int main(){
        int T = 0;
        string s1,s2;
        cin >> T;
        for(int i = 0; i < T; ++i){
            int minimo = 0, maximo = 0;
            cin >> s1 >> s2;
            for (int j = 0; j < s1.size(); ++j){
                if (s1[j] != s2[j]){
                    if (s1[j] != '?' && s2[j] != '?') minimo++;
                    maximo++;
                }
                else if (s1[j] == '?' && s2[j] == '?') maximo++;
            }
            cout << minimo << " " << maximo << "\n";
        }
        return 0;
    }

No comments:

Post a Comment