๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
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
int minimumCost(int input1, int input2, int input3, int **input4) {
    int N = input1;
    int M = input2;
    int K = input3;

    unordered_map<int, int> degree;

    for (int i = 0; i < M; ++i) {
        int u = input4[i][0];
        int v = input4[i][1];
        degree[u]++;
        degree[v]++;
    }

    int count = 0;
    for (const auto& pair : degree) {
        if (pair.second > 1) {
            count++;
        }
    }

    return count * K;
}


Desmus and the Check Centersโœ…
SELECT 
    i.invoice_number,
    c.customer_name,
    COUNT(co.id) AS number_of_contacts
FROM
    customer c
JOIN
    invoice i ON c.id = i.customer_id
LEFT JOIN
    contact co ON c.id = co.customer_id AND co.contact_start_time < i.invoice_date
LEFT JOIN
    user_account ua ON co.user_account_id = ua.id
WHERE
    i.user_account_id NOT IN (
        SELECT DISTINCT user_account_id
        FROM contact
        WHERE customer_id = c.id AND contact_start_time < i.invoice_date
    )
GROUP BY
    i.id, c.id
ORDER BY
    i.invoice_number ASC
๐Ÿ‘1
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
int minimumPower(vector<int>& cells) {
    priority_queue<int, vector<int>, greater<int>> minHeap(cells.begin(), cells.end());
   
    int totalPower = 0;
        while (minHeap.size() > 1) {
        int first = minHeap.top();
        minHeap.pop();
        int second = minHeap.top();
        minHeap.pop();
       
        int power = first + second;
        totalPower += power;
       
        minHeap.push(power);
    }
   
    return totalPower;
}



MINPOWERโœ…
Linkedin
import heapq

def getMinimumCost(cost, k):
    n = len(cost)
    dp = [float('inf')] * n
    dp[0] = 0
    heap = [(0, 0)]
   
    for i in range(1, n):
        while heap and heap[0][1] < i - k:
            heapq.heappop(heap)
       
        dp[i] = heap[0][0] + cost[i]
        heapq.heappush(heap, (dp[i], i))
   
    return dp[-1]

Minimum Costโœ…
Linkedin
SELECT 
    CASE
        WHEN t.table_name = 'offline_sites' THEN 'Offline'
        WHEN t.table_name = 'online_sites' THEN 'Online'
        WHEN t.table_name = 'suspended_sites' THEN 'Suspended'
    END AS status,
    COUNT(*) AS total_sites
FROM (
    SELECT 'offline_sites' AS table_name, customer_id, domain_name, is_active FROM offline_sites
    UNION ALL
    SELECT 'online_sites' AS table_name, customer_id, domain_name, is_active FROM online_sites
    UNION ALL
    SELECT 'suspended_sites' AS table_name, customer_id, domain_name, is_active FROM suspended_sites
) t
JOIN customers c ON t.customer_id = c.id
WHERE c.is_active = 1 AND t.is_active = 1
GROUP BY t.table_name
ORDER BY
    CASE
        WHEN t.table_name = 'offline_sites' THEN 1
        WHEN t.table_name = 'online_sites' THEN 2
        WHEN t.table_name = 'suspended_sites' THEN 3
    END;

Meesho online, offline, suspendedโœ…
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
SELECT 
    c.name,
    ROUND(SUM(CASE WHEN EXTRACT(QUARTER FROM t.dt) = 1 THEN t.amount ELSE 0 END), 2) AS q1_amount,
    ROUND(SUM(CASE WHEN EXTRACT(QUARTER FROM t.dt) = 2 THEN t.amount ELSE 0 END), 2) AS q2_amount,
    ROUND(SUM(CASE WHEN EXTRACT(QUARTER FROM t.dt) = 3 THEN t.amount ELSE 0 END), 2) AS q3_amount,
    ROUND(SUM(CASE WHEN EXTRACT(QUARTER FROM t.dt) = 4 THEN t.amount ELSE 0 END), 2) AS q4_amount,
    COUNT(t.coin_id) AS total_transactions,
    ROUND(SUM(t.amount), 2) AS total_amount
FROM
    coins c
LEFT JOIN
    transactions t ON c.id = t.coin_id AND EXTRACT(YEAR FROM t.dt) = 2023
GROUP BY
    c.name
ORDER BY
    c.name ASC;

Meesho cryptoโœ…
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll solve(ll n)
{
    vector<ll>bin(32);
    ll i=0;
    while(n)
    {
        bin[i]=n%2;
        n=n/2;
        i++;
    }
    string s;
    for(ll j=i-1;j>=0;j--) s.push_back((char)(bin[j]+'0'));
    //cout<<s<<endl;
    n=s.length();
    ll ans=0,f=1;
    for(ll i=0;i<n;i++)
    {
        ll dig=s[i]-'0';
        ll p=dig>0?pow(2,n-(i+1)):0;
        ll st=dig*(2*p-1);
        ans+=st*f;
        if(dig==0) f=1;
        else f=-1;
    }
    return ans;
}
signed main()
{
    ll n; cin>>n;
    cout<<solve(n);
}

Binary Manipulation โœ