๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
9.52K subscribers
5.56K photos
3 videos
95 files
9.69K 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 calculateTotalRegion(heights):
    n = len(heights)
    left = [-1] * n
    right = [n] * n
    stack = []
    for i in range(n):
        while stack and heights[stack[-1]] < heights[i]:
            right[stack.pop()] = i
        stack.append(i)
    stack.clear()
    for i in range(n - 1, -1, -1):
        while stack and heights[stack[-1]] < heights[i]:
            left[stack.pop()] = i
        stack.append(i)
   
    total = 0
    for i in range(n):
        region_length = right[i] - left[i] - 1
        total += region_length

    return total


LinkedIn โœ…
long long minimumWeeklyInput(vector<int> costs, int weeks)
{
    int n = costs.size();
    vector<vector<long long>> dp(n + 1, vector<long long>(weeks + 1, 1e18));

    dp[0][0] = 0;

    for (int w = 1; w <= weeks; ++w)
    {
        for (int i = 1; i <= n; ++i)
        {
            long long max_cost_in_week = 0;
            for (int k = i; k > 0; --k)
            {
                max_cost_in_week = max(max_cost_in_week, (long long)costs[k - 1]);
                if (dp[k - 1][w - 1] != 1e18)
                {
                    dp[i][w] = min(dp[i][w], dp[k - 1][w - 1] + max_cost_in_week);
                }
            }
        }
    }
    return dp[n][weeks];
}

LinkedIn โœ…
vector<long> getProcessTime(vector<int> time) { 
int n=time.size();
vector<array<long long,2>>dp(n,{LLONG_MIN,LLONG_MIN});
function<long long(int,int)>f=[&](int i, int dff){
    if(i==n) return 0LL;
    if(dp[i][dff]!=LLONG_MIN){
        return dp[i][dff];
    }
    long long res;
    if(dff==0){
        res=max(f(i+1,0)-time[i],f(i+1,1)+time[i]);
    }
    else{
        res=min(f(i+1,1)+time[i],f(i+1,0)-time[i]);
    }
    dp[i][dff]=res;
    return res;
};
long long ans=f(0,0);
long long s=accumulate(time.begin(),time.end(),0LL);
return {(s+ans)>>1,(s-ans)>>1};
}


Linkedlnโœ…
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
string parseURL(const string &url)
{
    string ans;
    string protocol;
    size_t pos = url.find("://");
    if (pos != string::npos)
    {
        protocol = url.substr(0, pos);
        ans += protocol;
    }

    string rest = url.substr(pos + 3);
    string hostname;
    pos = rest.find('/');
    if (pos != string::npos)
    {
        hostname = rest.substr(0, pos);
        ans += " ";
        ans += hostname;
        rest = rest.substr(pos + 1);
    }
    else
    {
        hostname = rest;
        ans += " ";
        ans += hostname;
        rest = "";
    }

    if (!rest.empty())
    {
        size_t query_pos = rest.find('=');
        string filename;
        if (query_pos != string::npos)
        {
            while (query_pos != string::npos)
            {
                filename = rest.substr(0, query_pos);
                string query = rest.substr(query_pos + 1);
                size_t temp = query.find('&');
                if (temp == string::npos)
                {
                    ans += " ";
                    ans += "[";
                    ans += filename;
                    ans+=":";
                ans+=" ";
                    ans += query;
                    ans += ']';
                    break;
                }
                string last = query.substr(0, temp);
                string last1 = query.substr(temp + 1);
                query_pos = last1.find('=');
                rest = last1;
                ans += " ";
                ans += "[";
               
                ans += filename;
                ans+=":";
                ans+=" ";
                ans += last;
                ans += ']';
            }
        }
        else
        {
           ans+=" ";
           ans+=rest;
        }
    }
    return ans;
}

URL Parser โœ…
Dunnhumby
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
using ll = long long;
using namespace std;
ll maxEvenSum(vector<ll>& t) {
    ll a = 0;
    ll s = INT_MAX;
    for (ll i : t) {
        a += i;
        if (i % 2 != 0) {
            s = min(s, i);
        }
    }
    if (a % 2 == 0) {
        return a;
    }
    return a- s;
}


Twilio โœ…
Company: Texas Instruments
Batch: 2022/2023/2024
Role: Software Engineer- AI & DL Location: Bangalore.

Skills: C/ C++, Machine learning/Deep Learning

Education: B.Tech/M.Tech 
Experience: 0.3 months - 22 months

Interested candidates email your profiles to namrata.kotur@spectrumconsultants.com
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
import sys
import threading

class FenwickTree:
    def __init__(self, size):
        self.n = size + 2
        self.tree = [0] * self.n
   
    def update(self, idx):
        while idx < self.n:
            self.tree[idx] += 1
            idx += idx & -idx
   
    def query(self, idx):
        res = 0
        while idx > 0:
            res += self.tree[idx]
            idx -= idx & -idx
        return res
       
def main():
    sys.setrecursionlimit(1 << 25)
    n = int(sys.stdin.readline())
    ranges = []
    for i in range(n):
        x, y = map(int, sys.stdin.readline().split())
        ranges.append((x, y, i))
   
    rangesSorted = sorted(ranges, key=lambda x: (x[0], -x[1]))
    endPoints = sorted(list(set([y for x, y, _ in rangesSorted])))
    yMapping = {y: idx+1 for idx, y in enumerate(endPoints)}
   
    ft = FenwickTree(len(yMapping))
    contains = [0] * n
   
    for x, y, idx in rangesSorted:
        contains[idx] = ft.query(len(yMapping)) - ft.query(yMapping[y]-1)
        ft.update(yMapping[y])
   
    rangesSortedRev = sorted(ranges, key=lambda x: (-x[0], x[1]))
   
    ftRev = FenwickTree(len(yMapping))
    containedBy = [0] * n
   
    for x, y, idx in rangesSortedRev:
        containedBy[idx] = ftRev.query(yMapping[y])
        ftRev.update(yMapping[y])
   
    print(' '.join(map(str, containedBy)))
    print(' '.join(map(str, contains)))

threading.Thread(target=main).start()


Kickdrum โœ