๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
9.63K subscribers
5.61K photos
3 videos
95 files
10.6K 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
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
#include <unordered_map>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

class designCache {
public:
    class Node {
    public:
        int key;
        int val;
        Node* prev;
        Node* next;

        Node(int key, int val) {
            this->key = key;
            this->val = val;
        }
    };

    Node* head = new Node(-1, -1);
    Node* tail = new Node(-1, -1);

    int cap;
    unordered_map<int, Node*> m;

    designCache(int capacity) {
        cap = capacity;
        head->next = tail;
        tail->prev = head;
    }

    void addNode(Node* newnode) {
        Node* temp = head->next;

        newnode->next = temp;
        newnode->prev = head;

        head->next = newnode;
        temp->prev = newnode;
    }

    void deleteNode(Node* delnode) {
        Node* prevv = delnode->prev;
        Node* nextt = delnode->next;

        prevv->next = nextt;
        nextt->prev = prevv;
    }

    int get(int key) {
        if (m.find(key) != m.end()) {
            Node* resNode = m[key];
            int ans = resNode->val;

            m.erase(key);
            deleteNode(resNode);
            addNode(resNode);

            m[key] = head->next;
            return ans;
        }
        return -1;
    }

    void put(int key, int value) {
        if (m.find(key) != m.end()) {
            Node* curr = m[key];
            m.erase(key);
            deleteNode(curr);
        }

        if (m.size() == cap) {
            m.erase(tail->prev->key);
            deleteNode(tail->prev);
        }

        addNode(new Node(key, value));
        m[key] = head->next;
    }
};

int main() {
    string attribs, attrib;
    getline(cin, attribs);
    stringstream ss(attribs);
    int capacity, key, val;
    cin >> capacity;
    designCache obj(capacity);
    while (getline(ss, attrib, ' ')) {
        if (attrib == "put") {
            cin >> key >> val;
            obj.put(key, val);
            cout << "null ";
        } else if (attrib == "get") {
            cin >> key;
            val = obj.get(key);
            cout << val << " ";
        }
    }
    return 0;
}


Atlan Fellowship โœ…
def longestChain(ws):
    wset, memo = set(ws), {}
   
    def cl(w):
        if w not in wset: return 0
        if w in memo: return memo[w]
        ml = 1
        for i in range(len(w)):
            ml = max(ml, 1 + cl(w[:i] + w[i+1:]))
       
        memo[w] = ml
        return ml
    return max(cl(w) for w in ws)


UI Path longest chainโœ…
def waysToChooseSum(lowLimit, highLimit):
    ds, mw, wc = [0] * 46, 0, 0
   
    for n in range(lowLimit, highLimit + 1):
        s = sum(int(d) for d in str(n))
        ds[s] += 1
        mw = max(mw, ds[s])

    for c in ds:
        if c == mw:
            wc += 1

    return [mw, wc]

Way to chooose sumโœ…
def transformString(s, t):
    def st(char):
        return 'ab' if char == 'z' else chr(ord(char) + 1)
    length = len(s)
    for _ in range(t):
        new_s = ''
        for char in s:
            new_s += st(char)
        s = new_s
        length = len(s)
    return length % (10**9 + 7)

Warner Bros โœ…
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
#include<bits/stdc++.h>
using namespace std;

class Trie {
public:
    map<int, int> hot;
    map<int, unordered_map<int, int>> trie;
    map<int, int> index;
    int curr = 0;

    void insert(string& s, int ind) {
        int p = 0;
        for (int i = 0; i < s.size(); i++) {
            int temp = s[i] - '0';
            if (trie.count(p) == 0 || trie[p].count(temp) == 0) {
                trie[p][temp] = ++curr;
            }
            p = trie[p][temp];
            index[p] = ind;
        }
        hot[p]++;
    }

    int longest_pref(string& s, int ind) {
        int p = 0;
        int last_ind = -1;
        for (int i = 0; i < s.size(); i++) {
            if (trie.count(p) == 0 || trie[p].count(s[i] - '0') == 0) break;
            p = trie[p][s[i] - '0'];
            last_ind = index[p];
        }
        insert(s, ind);
        return last_ind;
    }
};

vector<int> autocomplete(vector<string> command) {
    vector<int> result;
    Trie* t = new Trie();

    for (int i = 0; i < command.size(); i++) {
        int val = t->longest_pref(command[i], i);
        if (val == -1 && i == 0) result.push_back(0);
        else if (val == -1) result.push_back(i);
        else result.push_back(val + 1);
    }

    delete t;
    return result;
}


BNY (intern) โœ…
๐Ÿ‘2
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
#include <bits/stdc++.h>
using namespace std;

vector<long> bitwiseEquations(vector<long> a, vector<long> b)
{
    int n = a.size();
    vector<long> ans(n);

    for (int i = 0; i < n; i++)
    {
        if (a[i] < b[i])
        {
            ans[i] = 0;
            continue;
        }

        long x = 0, y = 0;
        long diff = (a[i] - b[i]) / 2;

        for (int j = 0; j < 64; j++)
        {
            if (b[i] & (1LL << j))
            {
                if ((diff & (1LL << j)) == 0)
                {
                    y |= (1LL << j);
                }
                else
                {
                    x = 0;
                    y = 0;
                    break;
                }
            }
            else
            {
                if ((diff & (1LL << j)))
                {
                    x |= (1LL << j);
                    y |= (1LL << j);
                }
            }
        }

        ans[i] = 2 * x + 3 * y;
    }

    return ans;
}


bitwiseEquations
BNY (Intern) โœ…
Zopsmart is hiring!
We are inviting campus placement cells to participate in ZopSmart Campus Hiring (1 Year internship plus FTE) for a batch of 2025 (should be able to join from the 1st week of October 2024).
Please reach out to
padmavathi.s@zopsmart.com & vinayak.sattigeri@zopsmart.com
Location - Bangalore HSR Layout
def solve(start, stop):
    def ss(num):
        num_str = str(num)
        for char in num_str:
            digit = int(char)
            if digit == 0 or num % digit != 0:
                return False
        return True
    total_sum = 0
    for num in range(start, stop + 1):
        if ss(num):
            total_sum += num
    return total_sum


Motorq โœ