Thursday, August 11, 2022
HomeSoftware DevelopmentRely of strings that comprises each String of one other Array as...

Rely of strings that comprises each String of one other Array as Subset


#embrace <bits/stdc++.h>

utilizing namespace std;

  

int countcommon(vector<string> A, vector<string> B, int N,

                int M)

{

  

    

    

    

    int max_freq[26] = { 0 };

    int ans = 0;

    for (int i = 0; i < M; i++) {

        int temp[26] = { 0 };

        for (int j = 0; j < B[i].measurement(); j++) {

            temp[B[i][j] - 'a']++;

        }

        for (int ok = 0; ok < 26; ok++) {

            max_freq[k] = max(max_freq[k], temp[k]);

        }

    }

  

    

    

    for (int i = 0; i < N; i++) {

        int temp[26] = { 0 };

        for (int j = 0; j < A[i].measurement(); j++) {

            temp[A[i][j] - 'a']++;

        }

        bool f = false;

        for (int ok = 0; ok < 26; ok++) {

            if (max_freq[k] > temp[k]) {

                f = true;

                break;

            }

        }

        if (f == false)

            ans++;

    }

  

    

    return ans;

}

  

int predominant()

{

    vector<string> A{ "geekolymic", "google", "amazon" };

    vector<string> B{ "go" };

    int N = A.measurement();

    int M = B.measurement();

    cout << countcommon(A, B, N, M) << endl;

    return 0;

}

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments