๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
9.55K subscribers
5.57K photos
3 videos
95 files
9.79K links
๐ŸšฉMain Group - @SuperExams
๐Ÿ“Job Updates - @FresherEarth

๐Ÿ”ฐAuthentic Coding Solutions(with Outputs)
โš ๏ธDaily Job Updates
โš ๏ธHackathon Updates & Solutions

Buy ads: https://telega.io/c/cs_algo
Download Telegram
int solve(int initial, vector<int> deltas) {
    int health = initial;
    for (int d : deltas) {
        health += d;
        if (health < 0) {
            health = 0;
        } else if (health > 100) {
            health = 100;
        }
    }
    return health;
}

Autodesk โœ…
vector<string> solve(vector<vector<string>> p, vector<string> a, int w) {
    vector<string> r;
    r.push_back(string(w + 2, '*'));
    for(int i = 0; i < p.size(); i++) {
        string l = "";
        for(string wd : p[i]) {
            if(l.size() + wd.size() + (l.empty() ? 0 : 1) > w) {
                if(a[i] == "LEFT") {
                    l += string(w - l.size(), ' ');
                } else if(a[i] == "RIGHT") {
                    l = string(w - l.size(), ' ') + l;
                }
                r.push_back("*" + l + "*");
                l = "";
            }
            if(!l.empty()) {
                l += " ";
            }
            l += wd;
        }
        if(!l.empty()) {
            if(a[i] == "LEFT") {
                l += string(w - l.size(), ' ');
            } else if(a[i] == "RIGHT") {
                l = string(w - l.size(), ' ') + l;
            }
            r.push_back("*" + l + "*");
        }
    }
    r.push_back(string(w + 2, '*'));
    return r;
}

Autodesk โœ…
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
struct Node{
    Node* links[10];
    bool end=false;
    bool containskey(char ch){
        return links[ch-'0']!=NULL;
    }
    void put(char ch,Node* node){
        links[ch-'0']=node;
    }
    Node* get(char ch){
        return links[ch-'0'];
    }
    void end1(){
        end=true;
    }
    bool isend(){
        return end;
    }
};
class Trie{
    private:
    Node* root;
    public:
    Trie() {
       root=new Node();
    }
   
    void insert(string word) {
        int l=word.size();
        Node* node=root;
        for(int i=0;i<l;i++)
        {
            if(!node->containskey(word[i]))
            {
                node->put(word[i],new Node());
            }
            node=node->get(word[i]);
        }
        node->end1();
    }
   
    int search(string word) {
        int l=word.size();
        Node* node=root;
        int ans=0;
        for(int i=0;i<l;i++)
        {
            if(!node->containskey(word[i]))
            {
                return ans;
            }
            else{
                ans++;
            }
            node=node->get(word[i]);
        }
        return ans;
    }
};

ll solve(vector<ll>a,vector<ll>b){
    Trie* t=new Trie;
   for(auto x:a){
       string s=to_string(x);
    t->insert(s);
      
   }
   int ans=0;
   for(auto x:b){
       string s=to_string(x);
       ans=max(ans,t->search(s));
   }
   return ans;
}
Autodesk โœ…
int solve(int N, int k, vector<int>& d) {
    vector<bool> dislike(10, false);
    for (int i = 0; i < k; ++i) {
        dislike[d[i]] = true;
    }

    while (true) {
        int temp = N;
        bool found = false;
        while (temp > 0) {
            if (dislike[temp % 10]) {
                found = true;
                break;
            }
            temp /= 10;
        }
        if (!found) {
            return N;
        }
        ++N;
    }
}

Minimum Amount โœ…
string shift(string s) {
    string minStr = s;
    for(int i=0; i<s.size(); i++) {
        s = s.substr(1) + s[0];
        if(s < minStr) {
            minStr = s;
        }
    }
    return minStr;
}

int solve(vector<int> a) {
    map<string, int> m;
    for(int i=0; i<a.size(); i++) {
        string s = to_string(a[i]);
        string minStr = shift(s);
        m[minStr]++;
    }
    int count = 0;
    for(auto it=m.begin(); it!=m.end(); it++) {
        int n = it->second;
        count += (n*(n-1))/2;
    }
    return count;
}

Autodesk โœ…
vector<string> solve(vector<string> s, vector<string> a) {
    vector<string> r;
    for (auto& song : s) {
        string sn;
        int sl;
        istringstream ss(song);
        getline(ss, sn, ':');
        ss >> sl;

        for (auto& anim : a) {
            string an;
            int al;
            istringstream as(anim);
            getline(as, an, '/');
            as >> al;

            if (sl % al == 0) {
                r.push_back(an + ":" + to_string(sl / al));
                break;
            }
        }
    }
    return r;
}

Tradedesk โœ…
import java.util.*;
public class Main {
    public int solution(int[] A, int X, int Y) {
        if (A == null || A.length < 1) return 0;
        Arrays.sort(A);
        int r = Integer.MAX_VALUE;
        for (int i = 0, j = 0, left = 0, right = 0;;) {
            for (; j < A.length - i && (left + A[j]) <= right; left += A[j++])
            ;
            r = Math.min(r, X * Math.max(A.length - j - i, 0) + Y * i);
            if (++i > A.length) break;
            right += A[A.length - i];
           
        }
        return r;
    }

Tradedesk โœ