๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
9.52K subscribers
5.56K photos
3 videos
95 files
9.72K 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
#include <bits/stdc++.h>
using namespace std;

int solve(vector<vector<int>>& mat) {
    int m = mat.size();
    int n = mat[0].size();
   
    vector<vector<int>> dp(m, vector<int>(n, 0));

    dp[m-1][n-1] = 1;
   
    for (int j = n - 2; j >= 0; --j) {
        dp[m-1][j] = max(1, dp[m-1][j+1] - mat[m-1][j]);
    }

    for (int i = m - 2; i >= 0; --i) {
        dp[i][n-1] = max(1, dp[i+1][n-1] - mat[i][n-1]);
    }

    for (int i = m - 2; i >= 0; --i) {
        for (int j = n - 2; j >= 0; --j) {
            int mini = min(dp[i+1][j], dp[i][j+1]);
            dp[i][j] = max(1, mini - mat[i][j]);
        }
    }
   
    return dp[0][0];
}

int main() {
    int m, n;
    cin >> m >> n;
    vector<vector<int>> mat(m, vector<int>(n));
   
    for (int i = 0; i < m; i++) {
        for (int j = 0; j < n; j++) {
            cin >> mat[i][j];
        }
    }
   
    cout << solve(mat) << endl;
   
    return 0;
}

Minimum strength to reach destinationโœ…
Samsung
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

const int MAXN = 1000;

vector<int> adjA[MAXN + 1];
vector<int> adjB[MAXN + 1];
bool visA[MAXN + 1];
bool visB[MAXN + 1];

void bfs(int s, vector<int> adj[], vector<int>& comp, bool vis[]) {
    queue<int> q;
    q.push(s);
    vis[s] = true;
    comp.push_back(s);
   
    while (!q.empty()) {
        int u = q.front(); q.pop();
        for (int v : adj[u]) {
            if (!vis[v]) {
                vis[v] = true;
                comp.push_back(v);
                q.push(v);
            }
        }
    }
}

void findComp(int n, vector<int> adj[], vector<vector<int>>& comps, bool vis[]) {
    fill(vis, vis + n + 1, false);

    for (int i = 1; i <= n; ++i) {
        if (!vis[i]) {
            vector<int> comp;
            bfs(i, adj, comp, vis);
            comps.push_back(comp);
        }
    }
}

int main() {
    int n, m1, m2;
    cin >> n >> m1 >> m2;

    for (int i = 0; i < m1; ++i) {
        int u, v;
        cin >> u >> v;
        adjA[u].push_back(v);
        adjA[v].push_back(u);
    }

    for (int i = 0; i < m2; ++i) {
        int u, v;
        cin >> u >> v;
        adjB[u].push_back(v);
        adjB[v].push_back(u);
    }

    vector<vector<int>> compsA, compsB;
    findComp(n, adjA, compsA, visA);
    findComp(n, adjB, compsB, visB);

    int numCompA = compsA.size();
    int numCompB = compsB.size();

    int maxEdges = (numCompA - 1) * (numCompB - 1);

    cout << maxEdges << endl;

    return 0;
}


Samsung โœ…
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
using namespace std;

vector<int>f(vector<int>&r,vector<int>&b,int cost){
    int n=r.size();
    int temp=0;
    vector<int>ans;
    ans.push_back(temp);
    bool flag=true;
    for(int i=0;i<n;i++){
        if(flag){
            if(r[i]<b[i]+cost){
                temp+=r[i];
            }
            else{
                temp+=b[i]+cost;
                flag=false;
            }
        }
        else{
            if(r[i]<b[i]){
                temp+=r[i];
                flag=true;
            }
            else{
                temp+=b[i];
            }
        }
        ans.push_back(temp);
    }
    return ans;
}
int main() {
  int n;
  cin>>n;
  vector<int>r(n),b(n);
  for(int i=0;i<n;i++){
      cin>>r[i];
  }
  for(int i=0;i<n;i++){
      cin>>b[i];
  }
  int cost;
  cin>>cost;
  vector<int>ans=f(r,b,cost);
  for(auto i:ans)cout<<i<<" ";
  return 0;
}

Red Blue
Oracle โœ…
๐Ÿš€ Join Our Team as an HR Business Partner at Amazon Operations! ๐Ÿš€

Are you a strategic HR leader ready to influence and drive organizational effectiveness in a dynamic, 24/7 environment? We're seeking a seasoned HRBP with a passion for shaping HR strategies that align with business goals and foster a high-engagement culture.

Key Responsibilities:

Lead and inspire a team of HR professionals in a high-growth environment.

Design and implement policies that drive continual improvement in business objectives.

Partner with leadership to integrate Amazonโ€™s Leadership Principles into our talent system.

Operate with autonomy to solve problems and craft integrated solutions across the employee lifecycle.

If you're ready to take on a challenging and rewarding role, please send your resume to nesinha@amazon.com. Let's shape the future together!
#include <bits/stdc++.h>
using namespace std;
int xorSubsequence(int a[], int n, int k)
{
    int ans = 0;
    map<int, int> map;

    int dp[n] = { 0 };

    map[a[0]] = 1;
    dp[0] = 1;

    for (int i = 1; i < n; i++) {
        dp[i] = max(dp[i], map[a[i] ^ k] + 1);
        ans = max(ans, dp[i]);
   
        map[a[i]] = max(map[a[i]], dp[i]);
    }

    return ans >= 2 ? ans : 0;
}


IONโœ…
def getString(input_str):
    stack = []
    last_occurrence = {c: i for i, c in enumerate(input_str)}
    seen = set()

    for i, char in enumerate(input_str):
        if char not in seen:
            while stack and char > stack[-1] and i < last_occurrence[stack[-1]]:
                seen.remove(stack.pop())
            stack.append(char)
            seen.add(char)

    return ''.join(stack)

IONโœ…
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
vector<int> runningMedian(vector<int> arr) {
    priority_queue<int> low;
    priority_queue<int, vector<int>, greater<int>> high;
    vector<int> res;
   
    for (int num : arr) {
        low.push(num);
        high.push(low.top());
        low.pop();
        if (low.size() < high.size()) {
            low.push(high.top());
            high.pop();
        }
        res.push_back(low.top());
    }
    return res;



RunningMedium โœ…
ION