CODE WITH VIRUS
865 subscribers
499 photos
36 files
115 links
Download Telegram
Valuable String
C++
GFG Weekly Coding Contest 95


string valuableString(int n, vector<string> &arr)
    {
        int mx = INT_MIN;
        string ans = "";
        for(int i=0;i<arr.size();i++)
        {
            string str = arr[i];
            int v = 0;
            int c = 0;
            for(int i=0;i<str.length();i++)
            {
                if(str[i]=='a' str[i]=='e' str[i]=='i' str[i]=='o' str[i]=='u')
                {
                    v++;
                }
                else
                {
                    c++;
                }
            }
            // cout<<c<<" "<<v<<endl;
            if(abs(c-v) > mx)
            {
                mx = abs(c-v);
                ans = arr[i];
            }
        }
        return ans;
    }

Valuable String
C++
GFG
Weekly Coding Contest 95
๐Ÿ‘3
Valuable String
C++
GFG Weekly Coding Contest 95


string valuableString(int n, vector<string> &arr)
    {
        int mx = INT_MIN;
        string ans = "";
        for(int i=0;i<arr.size();i++)
        {
            string str = arr[i];
            int v = 0;
            int c = 0;
            for(int i=0;i<str.length();i++)
            {
                if(str[i]=='a' str[i]=='e' str[i]=='i' str[i]=='o' str[i]=='u')
                {
                    v++;
                }
                else
                {
                    c++;
                }
            }
            // cout<<c<<" "<<v<<endl;
            if(abs(c-v) > mx)
            {
                mx = abs(c-v);
                ans = arr[i];
            }
        }
        return ans;
    }

Valuable String
C++
GFG Weekly Coding Contest 95
Stone Bags
C++
GFG Weekly Coding Contest 95

class Solution {
  public:
    int stoneBags(int n, vector<int> &arr) {
        sort(arr.begin(),arr.end());
        map<int,int>mp;
        for(int i=0;i<n;i++){
            mp[arr[i]]++;
        }
        vector<int>ans;
        for(auto it: mp){
            ans.push_back(it.first);
        }
        if(ans.size()==1)
         return 0;
         else if(ans.size()==2) return abs(ans[0]-ans[1])*2;
         else{
             int m=ans.size();
             int res=0;
             for(int i=0;i<m-2;i++){
                 res=max(res,ans[m-1]-ans[i]+ans[i+1]-ans[i]);
             }
             for(int i=m-1;i>1;i--){
                 res=max(res,ans[i]-ans[0]+ans[i]-ans[i-1]);
             }
             return res;
         }
       
    }
};

Stone Bags
C++
GFG Weekly Coding Contest 95
๐Ÿ‘1
Permutation Making
C++
GFG Weekly Coding Contest 95


int makePermutation(int N, vector<int> &arr) {
        // code here
        set<int> st;
    vector<int> rem;
    
    // Storing one instance of every element
    // from 1 to N
    for (int i = 1; i <= N; i++) {
        st.insert(i);
    }

    for (int i = 0; i < N; i++) {
        if (st.find(arr[i]) != st.end())
            st.erase(arr[i]);
        else
            rem.push_back(arr[i]);
    }
    
    // Sorting in descending order
    sort(rem.begin(), rem.end());
    reverse(rem.begin(), rem.end());

    int pt = 0;
    bool flag = false;

    for (auto& x : rem) {
        auto it = st.end();
        it--;
        int p = (*it);
        if (p > (x - 1) / 2) {
            flag = true;
            break;
        }
        st.erase(it);
    }

    if (flag) {
        // Not possible to make permutation.
        return -1;
    }
    else {
        // Minimum number of operation required.
        return rem.size();
    }
    }

Permutation Making
C++
GFG Weekly Coding Contest 95
Tcs 2pm answers๐Ÿ‘‡

1)47

2)0.2

3)0.96

4)143.67

3)0.96
4)143.67
5)4

6)25

6)25
7)5.5
8)12%

9)77.14

11)720

10)43.75

13)7083

14)6hrs

11)720
12)226
13)7087

15)8km

16)880

17)99.5

18) 14
๐Ÿ‘1
CODE WITH VIRUS pinned ยซTcs 2pm answers๐Ÿ‘‡ 1)47 2)0.2 3)0.96 4)143.67 3)0.96 4)143.67 5)4 6)25 6)25 7)5.5 8)12% 9)77.14 11)720 10)43.75 13)7083 14)6hrs 11)720 12)226 13)7087 15)8km 16)880 17)99.5 18) 14ยป
Share and support
19)5875
Share this answers screenshot in large group ๐Ÿฅบ๐Ÿฅบ๐Ÿฅบ

Please share my channel guys ๐Ÿ˜Š
20)15
TCS PAID NQT

All solutions + information about IRC and DRC will be posted


https://youtube.com/@OnlineStudy4You

Subscribe now
Going to upload how to attend IRC

Subscribe fast https://youtube.com/@OnlineStudy4You
CODE WITH VIRUS pinned ยซTCS PAID NQT All solutions + information about IRC and DRC will be posted https://youtube.com/@OnlineStudy4You Subscribe nowยป
Video uploaded

https://youtu.be/tjg40CBqxtY
https://youtu.be/tjg40CBqxtY

Watch and subscribe please๐Ÿ™
TCS IRC and DRC coding solution
Python programming language
๐Ÿ‘1
JP Morgan
Python code
Fun with Anagrams