๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
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
SQL: Calendar Application Events Report 2
SELECT 
    e.dt,
    e.title,
    GROUP_CONCAT(CONCAT(g.full_name, ' <', g.email_address, '>') ORDER BY g.full_name SEPARATOR ', ') AS guests
FROM
    events e
JOIN
    events_guests eg ON e.id = eg.event_id
JOIN
    guests g ON eg.guest_id = g.id
WHERE
    g.on_vacation = 0
GROUP BY
    e.id, e.dt, e.title
ORDER BY
    e.dt ASC
LIMIT 5;
๐Ÿ‘1
def getMinCores(start, end):
    events = [(t, 1) for t in start] + [(t, -1) for t in end]
    events.sort(key=lambda x: (x[0], -x[1]))
    max_cores = 0
    current_cores = 0
    for time, event_type in events:
        if event_type == 1:
            current_cores += 1
        else:
            current_cores -= 1
        max_cores = max(max_cores, current_cores)
    return max_cores

Process Scheduler โœ…
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>
const int MOD = 1000000007;
using namespace std;
void dfs(int node, const unordered_map<int, vector<pair<int, int>>>& tree, vector<long long>& magnitudes) {
    auto it = tree.find(node);
    if (it != tree.end()) {
        for (const auto& neighbor : it->second) {
            int next_node = neighbor.first;
            int weight = neighbor.second;
            magnitudes[next_node] = (magnitudes[node] * weight) % MOD;
            dfs(next_node, tree, magnitudes);
        }
    }
}

vector<int> findEquivalentMagnitude(int unit_nodes, vector<int> unit_from, vector<int> unit_to, vector<int> unit_weight, int x) {
    unordered_map<int, vector<pair<int, int>>> tree;
    for (int i = 0; i < unit_from.size(); ++i) {
        tree[unit_from[i]].emplace_back(unit_to[i], unit_weight[i]);
    }
    vector<long long> magnitudes(unit_nodes + 1, -1);
    magnitudes[1] = x;

    dfs(1, tree, magnitudes);

    vector<int> result(unit_nodes);
    for (int i = 1; i <= unit_nodes; ++i) {
        result[i - 1] = magnitudes[i];
    }

    return result;
}
int findMaxUses(vector<int>& costs, vector<int>& uses, int budget) {
    int n = costs.size();
   
    if (n < 2) {
        return -1;
    }
   
    vector<pair<int, int>> ft;
    for (int i = 0; i < n; ++i) {
        ft.push_back({costs[i], uses[i]});
    }
   
    sort(ft.begin(), ft.end());
    int mu = -1;

    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            int tc = ft[i].first + ft[j].first;
           
            if (tc <= budget) {
                int bg = ft[i].second + ft[j].second;
                mu = max(mu, bg);
            } else {
                break;
            }
        }
    }
   
    return mu;
}

DE Shaw โœ…
int Find(vector<int>& people, int limit) {
        int ans=0;
        int i=0, j=people.size()-1;
        sort(people.begin(),people.end());
        if(people[n-1]>limit) return -1;
        while(i<=j){
             
            if(people[i]+people[j]<=limit){
                i++;
                j--;
            }else{
                j--;
            }
           
            ans++;
           
        }
       
       
       
        return ans;
    }

Airlift โœ…
WITH monthly_sales AS (
    SELECT mon, SUM(amount) as month_total
    FROM sales
    GROUP BY mon
),
cumulative_sales AS (
    SELECT mon,
           SUM(month_total) OVER (ORDER BY mon ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) as total_sales_so_far
    FROM monthly_sales
)
SELECT ms.mon,
       ROUND(ms.month_total * 100.0 / cs.total_sales_so_far, 0) AS sales_percent
FROM monthly_sales ms
JOIN cumulative_sales cs ON ms.mon = cs.mon
WHERE ms.mon > 1 AND ROUND(ms.month_total * 100.0 / cs.total_sales_so_far, 0) >= 20
ORDER BY ms.mon;


Sales percent โœ…
๐Ÿ‘1
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s=sc.next();
        int n=s.length(),i;
        double dp[][]=new double[n+1][2];
        dp[0][0]=0;
        dp[0][1]=1;
        double a[][]=new double[n][2];
        for(i=1;i<=n;i++){
            if(s.charAt(i-1)=='L'){
                dp[i][0]=dp[i-1][0];
                dp[i][1]=(double)(dp[i-1][0]+dp[i-1][1])/2;
                a[i-1][0]=dp[i][1];
                a[i-1][1]=(double)i;
            }
            else{
                dp[i][1]=dp[i-1][1];
                dp[i][0]=(double)(dp[i-1][0]+dp[i-1][1])/2;
                a[i-1][0]=dp[i][0];
                a[i-1][1]=(double)i;
            }
        }
        Arrays.sort(a,(x,y)->Double.compare(x[0],y[0]));
        int ans[]=new int[n];
        for(i=0;i<n;i++) ans[i]=(int)a[i][1];
        System.out.println(Arrays.toString(ans));
    }
}
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

vector<int> findNumberSequence(const string& direction) {
    int n = direction.size();
    vector<int> result((1 << n), -1);
    int lower = 0;
    int higher = (1 << n) - 1;

    for (int i = 0; i < n; i++) {
        int center = (lower + higher) / 2;
        result[center] = i + 1;

        if (direction[i] == 'L') {
            higher = center - 1;
        } else {
            lower = center + 1;
        }
    }

    result.erase(remove(result.begin(), result.end(), -1), result.end());
    return result;
}
๐Ÿ‘1