๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
9.52K subscribers
5.56K photos
3 videos
95 files
9.68K 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
private static long[] miniCost(int[] red, int[] blue, long blueCost) {
    int n = red.length;

    long[][] dp = new long[n + 1][2];
    dp[0][0] = 0;
    dp[0][1] = blueCost;
   
    long[] ans = new long[n + 1];

    for (int i = 1; i <= n; i++) {
        dp[i][0] = Math.min(dp[i - 1][0] + red[i - 1], dp[i - 1][1] + red[i - 1]);
        dp[i][1] = Math.min(dp[i - 1][1] + blue[i - 1], dp[i - 1][0] + blue[i - 1] + blueCost);
                ans[i] = Math.min(dp[i][0], dp[i][1]);
    }

    return ans;
}


Visiting Cities
Patym โœ…
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

int maxTransactions(vector<int>& transactions) {
    priority_queue<int, vector<int>, greater<int>> minHeap;
   
    long long sum = 0;
    int count = 0;    
    for (int i = 0; i < transactions.size(); i++) {
        sum += transactions[i];
        minHeap.push(transactions[i]);
        if (sum < 0) {
            int smallest = minHeap.top();
            sum -= smallest;
            minHeap.pop();    
        } else {
            count++;
        }
    }
   
    return count;
}


Bank Transactions โœ…
Patym
Capgemini Interview Experience

Self intro
Project explanation
More than five questions from project
What is SQL
Oops concepts fully explain
Data types
Local variable and global variable
Class and objective in python
Explain full join statement in SQL with example
How you take data of the student from student table based on some condition
How to convert string to integer
About python
Union and union all
What is your role in project
How did you clear error in your project
Difficulties in your project
What is your strength and weakness
How will you overcome your weakness
After five years in which technology you want to see your self
As a team leader what are the challenges you faced in your project
Suppose you are working in team facing challenges there is you have to alot work to some people will not aware of that work how will you handle this situation
Duration 30 minutes
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 โœ