๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
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
Capgemini Interview Experience

Self intro
What is oracle SQL (because I mentioned)
Project explanation
Difference between DBMS and RDBMS
Fragmentation in SQL
What is tickets ( I mentioned in my project)
Why you choose capgemini
Do you have any questions to ask
I replied yes then I asked what you think about capgemini for freshers
Then he asked are you comfortable with night shift and relocate to chennai or Bangalore
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
#include <vector>
#include <algorithm>
#include <iostream>
#include <climits>
using namespace std;
vector<int> solution(vector<vector<int>> m) {
    int r = m.size();
    int c = m[0].size();
    int resR = -1, resC = -1;
    long long minDiff = LLONG_MAX;
    for (int a = 0; a < r - 1; a++) {
        for (int b = 0; b < c - 1; b++) {
            long long s1 = 0, n1 = 0;
            long long s2 = 0, n2 = 0;
            long long s3 = 0, n3 = 0;
            long long s4 = 0, n4 = 0;
            for (int i = 0; i <= a; i++) {
                for (int j = 0; j <= b; j++) {
                    if (m[i][j] >= 0) {
                        s1 += m[i][j];
                        n1++;
                    }
                }
            }
            for (int i = 0; i <= a; i++) {
                for (int j = b + 1; j < c; j++) {
                    if (m[i][j] >= 0) {
                        s2 += m[i][j];
                        n2++;
                    }
                }
            }
            for (int i = a + 1; i < r; i++) {
                for (int j = 0; j <= b; j++) {
                    if (m[i][j] >= 0) {
                        s3 += m[i][j];
                        n3++;
                    }
                }
            }
            for (int i = a + 1; i < r; i++) {
                for (int j = b + 1; j < c; j++) {
                    if (m[i][j] >= 0) {
                        s4 += m[i][j];
                        n4++;
                    }
                }
            }
            long long avg1 = n1 > 0 ? s1 / n1 : 0;
            long long avg2 = n2 > 0 ? s2 / n2 : 0;
            long long avg3 = n3 > 0 ? s3 / n3 : 0;
            long long avg4 = n4 > 0 ? s4 / n4 : 0;
            vector<long long> avgs = {avg1, avg2, avg3, avg4};
            long long maxAvg = *max_element(avgs.begin(), avgs.end());
            long long minAvg = *min_element(avgs.begin(), avgs.end());
            long long diff = maxAvg - minAvg;
            if (diff < minDiff || (diff == minDiff && (a < resR || (a == resR && b < resC)))) {
                minDiff = diff;
                resR = a;
                resC = b;
            }
        }
    }
    return {resR, resC};
}


Visa โœ…
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
#include <iostream>
#include <queue>
#include <vector>
#include <tuple>
#include <climits>

using namespace std;

struct Point {
    int x, y;
};

const vector<Point> directions = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
vector<vector<int>> bfs(const vector<vector<int>>& maze, Point start) {
    int n = maze.size();
    int m = maze[0].size();
    vector<vector<int>> dist(n, vector<int>(m, INT_MAX));
    queue<Point> q;
    q.push(start);
    dist[start.x][start.y] = 0;

    while (!q.empty()) {
        Point current = q.front();
        q.pop();

        for (auto dir : directions) {
            int newX = current.x + dir.x;
            int newY = current.y + dir.y;
            if (newX >= 0 && newX < n && newY >= 0 && newY < m && maze[newX][newY] != 1) {
                if (dist[newX][newY] > dist[current.x][current.y] + 1) {
                    dist[newX][newY] = dist[current.x][current.y] + 1;
                    q.push({newX, newY});
                }
            }
        }
    }
   
    return dist;
}

int minMoves(vector<vector<int>>& maze, int x, int y) {
    int n = maze.size();
    int m = maze[0].size();
    vector<Point> coins;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (maze[i][j] == 2) {
                coins.push_back({i, j});
            }
        }
    }

    int coinCount = coins.size();
    if (coinCount == 0) {
        auto dist = bfs(maze, {0, 0});
        return dist[x][y] == INT_MAX ? -1 : dist[x][y];
    }

    vector<Point> positions = {{0, 0}}; 
    positions.insert(positions.end(), coins.begin(), coins.end());
    positions.push_back({x, y});
    int pSize = positions.size();
    vector<vector<int>> distMatrix(pSize, vector<int>(pSize, INT_MAX));

    for (int i = 0; i < pSize; ++i) {
        auto dist = bfs(maze, positions[i]);
        for (int j = 0; j < pSize; ++j) {
            distMatrix[i][j] = dist[positions[j].x][positions[j].y];
        }
    }
    for (int i = 0; i < pSize; ++i) {
        for (int j = 0; j < pSize; ++j) {
            if (distMatrix[i][j] == INT_MAX) {
                return -1;
            }
        }
    }
    int coinMaskSize = 1 << coinCount;
    vector<vector<int>> dp(coinMaskSize, vector<int>(coinCount, INT_MAX));
    for (int i = 0; i < coinCount; ++i) {
        dp[1 << i][i] = distMatrix[0][i + 1]; 
    }
    for (int mask = 0; mask < coinMaskSize; ++mask) {
        for (int i = 0; i < coinCount; ++i) {
            if (!(mask & (1 << i))) continue; 
            for (int j = 0; j < coinCount; ++j) {
                if (mask & (1 << j)) continue; 
                int newMask = mask | (1 << j);
                dp[newMask][j] = min(dp[newMask][j], dp[mask][i] + distMatrix[i + 1][j + 1]);
            }
        }
    }
    int minSteps = INT_MAX;
    for (int i = 0; i < coinCount; ++i) {
        minSteps = min(minSteps, dp[coinMaskSize - 1][i] + distMatrix[i + 1][pSize - 1]);
    }

    return minSteps;
}

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

using namespace std;

string ltrim(const string &);
string rtrim(const string &);


/*
* Complete the 'windFarms' function below.
*
* The function is expected to return an INTEGER.
* The function accepts following parameters:
*  1. INTEGER_ARRAY premium
*  2. INTEGER_ARRAY x
*  3. INTEGER_ARRAY y
*/
int findWeightedMedian(const vector<pair<int, int>>& coord_premium) {
    int total_weight = 0;
    for (const auto& cp : coord_premium) {
        total_weight += cp.second;
    }

    int sum = 0;
    for (const auto& cp : coord_premium) {
        sum += cp.second;
        if (sum >= (total_weight + 1) / 2) {
            return cp.first;
        }
    }
    return 0;
}

long long windFarms(const vector<int>& premium, const vector<int>& x, const vector<int>& y) {
    int n = premium.size();
    vector<pair<int, int>> x_premium(n), y_premium(n);

    for (int i = 0; i < n; ++i) {
        x_premium[i] = {x[i], premium[i]};
        y_premium[i] = {y[i], premium[i]};
    }

    sort(x_premium.begin(), x_premium.end());
    sort(y_premium.begin(), y_premium.end());

    int cx = findWeightedMedian(x_premium);
    int cy = findWeightedMedian(y_premium);

    long long total_cost = 0;
    for (int i = 0; i < n; ++i) {
        total_cost += static_cast<long long>(premium[i]) * (abs(x[i] - cx) + abs(y[i] - cy));
    }

    return total_cost;
}

LinkedIn โœ…
#!/bin/python3

import math
import os
import random
import re
import sys


#
# Complete the 'efficientTrek' function below.
#
# The function is expected to return an INTEGER.
# The function accepts following parameters:
#  1. INTEGER_ARRAY trails
#  2. INTEGER record
#
def efficientTrek(trails, record):
    n = len(trails)
        dp = [[float('inf')] * (record + 1) for _ in range(n + 1)]
    dp[0][0] = 0

    for j in range(1, record + 1): 
        for i in range(1, n + 1):
            max_length = 0 
            for k in range(i, 0, -1):
                max_length = max(max_length, trails[k - 1])
                dp[i][j] = min(dp[i][j], dp[k - 1][j - 1] + max_length)
               
    return dp[n][record]

LinkedIn โœ…
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