22.6 C
New York
Friday, September 27, 2024

Discover digits current in given jumbled String

Share To Your Friends

[ad_1]

  

#embody <bits/stdc++.h>

utilizing namespace std;

  

string findNumber(string S, int N)

{

    

    string ans = "";

  

    

    

    map<char, int> mp;

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

        mp[S[i]]++;

    }

  

    whereas (mp['z'] && mp['e'] && mp['r']

           && mp['o']) {

        mp['z']--;

        mp['e']--;

        mp['r']--;

        mp['o']--;

        ans += '0';

    }

    whereas (mp['o'] && mp['n'] && mp['e']) {

        mp['o']--;

        mp['n']--;

        mp['e']--;

        ans += '1';

    }

    whereas (mp['t'] && mp['w'] && mp['o']) {

        mp['t']--;

        mp['w']--;

        mp['o']--;

        ans += '2';

    }

    whereas (mp['t'] && mp['h'] && mp['r']

           && mp['e'] && mp['e']) {

        mp['t']--;

        mp['h']--;

        mp['r']--;

        mp['e']--;

        mp['e']--;

        ans += '3';

    }

    whereas (mp['f'] && mp['o'] && mp['u']

           && mp['r']) {

        mp['f']--;

        mp['o']--;

        mp['u']--;

        mp['r']--;

        ans += '4';

    }

    whereas (mp['f'] && mp['i'] && mp['v']

           && mp['e']) {

        mp['f']--;

        mp['i']--;

        mp['v']--;

        mp['e']--;

        ans += '5';

    }

    whereas (mp['s'] && mp['i'] && mp['x']) {

        mp['s']--;

        mp['i']--;

        mp['x']--;

        ans += '6';

    }

    whereas (mp['s'] && mp['e'] && mp['v']

           && mp['e'] && mp['n']) {

        mp['s']--;

        mp['e']--;

        mp['v']--;

        mp['e']--;

        mp['n']--;

        ans += '7';

    }

    whereas (mp['e'] && mp['i'] && mp['g']

           && mp['h'] && mp['t']) {

        mp['e']--;

        mp['i']--;

        mp['g']--;

        mp['h']--;

        mp['t']--;

        ans += '8';

    }

    whereas (mp['n'] && mp['i'] && mp['n']

           && mp['e']) {

        mp['n']--;

        mp['i']--;

        mp['n']--;

        mp['e']--;

        ans += '9';

    }

    return ans;

}

  

int fundamental()

{

    string s = "zerootwneozero";

    int N = s.measurement();

  

    

    cout << findNumber(s, N);

    return 0;

}

[ad_2]


Share To Your Friends

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles