๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
9.58K subscribers
5.59K photos
3 videos
95 files
10K 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
def stemmer(text):
    stemmed_text = []
    suffixes = ['ed', 'ly', 'ing']
   
    for word in text.split():
        if word.endswith(tuple(suffixes)):
            word = word[:-2] if word.endswith('ed') else word[:-3]
            if len(word) > 8:
                word = word[:8] 
        stemmed_text.append(word)
   
    return ' '.join(stemmed_text)

Suffix stripping stemmer โœ…
import pandas as pd


def saleorder(df):
    grouped = df.groupby(['date added', 'type'])
    for (_, group), (_, sold_group) in zip(grouped, grouped):
        if group['type'].iloc[0] == 'Received':
            received_sizes = group['sizes'].str.split('/').explode().unique()
            sold_sizes = sold_group['sizes'].str.split('/').explode().unique()
            if all(size in sold_sizes for size in received_sizes):
                print("Possible")
            else:
                print("Not Possible")



Verify Sale Orderโœ…
๐Ÿ‘1
class Message(object):
    def init(self, message: str, sender: int, receiver: int) -> None:
        self.message = message
        self.sender = sender
        self.receiver = receiver

    def str(self) -> str:
        return self.message

    def eq(self, other: object) -> bool:
        if not isinstance(other, Message):
            return False
        return self.message == other.message

Message Objects โœ…
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
def stemmer(text):     stemmed_text = []     suffixes = ['ed', 'ly', 'ing']         for word in text.split():         if word.endswith(tuple(suffixes)):             word = word[:-2] if word.endswith('ed') else word[:-3]             if len(word) > 8:                โ€ฆ
#include <iostream>
#include <sstream>
#include <string>
#include <vector>

std::string stemmer(const std::string& text) {
    std::stringstream ss(text);
    std::string word;
    std::vector<std::string> stemmed_words;

    while (ss >> word) {
        if (word.size() > 2 && (word.substr(word.size() - 2) == "ed" word.substr(word.size() - 2) == "ly" word.substr(word.size() - 3) == "ing")) {
            word = word.substr(0, word.size() - 2);
        }
        if (word.size() > 8) {
            word = word.substr(0, 8);
        }
        stemmed_words.push_back(word);
    }

    std::string result;
    for (const std::string& stemmed_word : stemmed_words) {
        result += stemmed_word + " ";
    }


    result.pop_back();
    return result;
}

int main() {
    std::string text = "an extremely dangerous dog is barking";
    std::cout << stemmer(text) << std::endl;  // Output: "an extreme dangerou dog is bark"

    return 0;
}

Suffix stripping stemmer โœ…
#include<bits/stdc++.h>

using namespace std;
const int maxn = 1e6+10;

int n, tr[4*maxn], a[maxn];

void build(int no, int l, int r) {
    if(l == r) {
        tr[no] = a[l];
        return;
    }
    int lc=2*no,rc=2*no+1,mid=(l+r)/2;

    build(lc,l,mid);
    build(rc,mid+1,r);
    tr[no] = (tr[lc]&tr[rc]);
}

int query(int no, int l, int r, int ll, int rr) {
    if(l > rr or r < ll) return ((1<<30)-1);
    if(l >= ll && r <= rr) return tr[no];
    int lc=2*no,rc=2*no+1,mid=(l+r)/2;
    return (query(lc,l,mid,ll,rr)&(query(rc,mid+1,r,ll,rr)));
}

long getZeroBitSubarrays(vector<int> arr) {
    n = arr.size();
    for(int i = 1; i <= n; i++) {
        a[i] = arr[i-1];
    }
    build(1,1,n);
    long ans = 0;
    int r = 0;
    for(int l = 1; l <= n; l++) {
        while(r+1 <= n && query(1,1,n,l,r+1) != 0) {
            r++;
        }
        ans+= n-r;
    }
    return ans;

}

int main() {

}

DE Shawโœ…
#include<bits/stdc++.h>

using namespace std;

long getMaxTotalEfficiency(vector<int> compatibility, vector<int> efficiency, int k) {
    int n = compatibility.size();
    vector<pair<int,int>> a;
    for(int i = 0; i < n; i++) {
        a.push_back(make_pair(compatibility[i],efficiency[i]));
    }

    multiset<int> s;
    long sum = 0;
    sort(a.begin(),a.end(),greater<pair<int,int>>());
    long ans = 0;
    for(int i = 0; i < n; i++) {
        s.insert(a[i].second);
        sum+= a[i].second;
        while(s.size() > k) {
            sum-= *s.begin();
            s.erase(s.begin());
        }
        if(s.size() == k) ans = max(ans,sum*a[i].first);
    }
    return ans;
}

int main() {
}

DE Shawโœ…
long long dfs(int node,vector<vector<int>> &graph,long long &cnt,int k,vector<int> &vis){

  long long val=1;
  vis[node]=1;
  for(auto x : graph[node]){
      if(vis[x]==0)
      val+=dfs(x,graph,cnt,k,vis);
  }


  if(node!=1){
      cnt+=((val+k-1)/k);
  }


  return val;


}
long getMinOperations(int k, int n, vector<int> f, vector<int> t) {

   vector<vector<int>> graph(n+1);
   for(int i=0;i<f.size();i++){
       graph[f[i]].push_back(t[i]);
       graph[t[i]].push_back(f[i]);
   }
   long long cnt=0;
   vector<int> vis(n+1,0);
   dfs(1,graph,cnt,k,vis);
   return cnt;
}

DE Shawโœ…
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int N;
    cin >> N;

    vector<long long> gardens(N);
    for (int i = 0; i < N; ++i) {
        cin >> gardens[i];
    }

    long long total_collected = 0;
    for (int i = 0; i < N; ++i) {
        if (gardens[i] > 10) {
            total_collected += gardens[i] - 10;
        }
    }

    cout << total_collected << endl;

    return 0;
}

Garden โœ…
int maxBalancedShipments(vector<int>&a) {
   
    int n=a.size();
    int ans=0;
    int prev=-1;
    bool f=0;
    for(int i=n-1;i>=0;i--)
    {
        if(prev==-1) { prev=a[i]; continue;}
        if(a[i]>prev) { f=1; ans++; prev=-1;}
        else if(f) prev=a[i];
    }
    return ans;
}

Amazon โœ