๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
9.63K subscribers
5.6K photos
3 videos
95 files
10.3K 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 dp[5001];

int F(int L, int N, int K, vector<int> &A) {
    if (L == N) return 0;
    if (dp[L] != -1) return dp[L];
    int ans = 2e9;
    int maxi = 0;
    for (int R = L; R < min(N,L + K); R++) {
        maxi = max(maxi, A[R]);
        ans = min(ans, maxi + F(R + 1, N, K, A));
    }
    return return dp[L] = ans;
}

int calculateCost(vector<int> arr, int threshold) {
    memset(dp, -1, sizeof dp);
    return F(0, arr.size(), threshold, arr);
}
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
bool can_walk_in_time(const vector<int>& pain, int N, long long T) {
    long long total_distance = 0;
    for (int p : pain) {
        if (p == 0) continue;
        long long max_distance = static_cast<long long>(sqrt(T / p));
        total_distance += max_distance;
        if (total_distance >= N) {
            return true;
        }
    }
    return total_distance >= N;
}
long long minTime(int N, vector<int> pain) {
    long long low = 0, high = 1e18;
    while (low < high) {
        long long mid = (low + high) / 2;
        if (can_walk_in_time(pain, N, mid)) {
            high = mid;
        } else {
            low = mid + 1;
        }
    }
    return low;
}

Nuclei Championship โœ…
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

bool canFormSubsequence(const string &s, const string &t, int left, int right) {
    int m = t.size(), n = s.size();
    int ti = 0;
    for (int si = 0; si < n; si++) {
        if (ti == left && ti <= right) {
            ti = right + 1; // Skip the window
        }
        if (ti < m && s[si] == t[ti]) {
            ti++;
        }
    }
    return ti == m;
}

int findMinScore(string &s, string &t) {
    int m = t.size(), n = s.size();
    if (m == 0) return 0;

    int left = 0, right = m - 1, answer = m;
   
    while (left <= right) {
        int mid = left + (right - left) / 2;
        bool possible = false;
       
        for (int i = 0; i + mid < m; i++) {
            if (canFormSubsequence(s, t, i, i + mid)) {
                possible = true;
                break;
            }
        }
       
        if (possible) {
            answer = mid + 1;
            right = mid - 1;
        } else {
            left = mid + 1;
        }
    }
   
    return answer;
}

int main() {
    string s, t;
    cin >> s >> t;
    cout << findMinScore(s, t) << endl;
    return 0;
}

The subsequence Mastery โœ…
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int dfs(vector<vector<int>>& grid, int i, int j, vector<vector<int>>& memo) {
    if (memo[i][j] != -1) return memo[i][j]; 
   
    int max_score = 0;
    int m = grid.size();
    int n = grid[0].size();
   
    for (int l = j + 1; l < n; ++l) {
        max_score = max(max_score, grid[i][l] - grid[i][j] + dfs(grid, i, l, memo));
    }
   
    for (int k = i + 1; k < m; ++k) {
        max_score = max(max_score, grid[k][j] - grid[i][j] + dfs(grid, k, j, memo));
    }
   
    memo[i][j] = max_score; 
    return max_score;
}

int maxMagicalMazeScore(vector<vector<int>>& grid) {
    int m = grid.size();
    int n = grid[0].size();
    vector<vector<int>> memo(m, vector<int>(n, -1));
   
    int max_score = 0;
    for (int i = 0; i < m; ++i) {
        for (int j = 0; j < n; ++j) {
            max_score = max(max_score, dfs(grid, i, j, memo));
        }
    }
   
    return max_score;
}

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

Max Magical Maze Score โœ…
#include<bits/stdc++.h>
using namespace std;

int memoize(int l, int r, int residue, const vector<char>& colors) {
    int n = colors.size();
    int dp[n][n][n];
    memset(dp, -1, sizeof(dp));

    if (r < l)
        return 0;
    else if (dp[l][r][residue] != -1)
        return dp[l][r][residue];

    dp[l][r][residue] = (residue + 1) * (residue + 1) + memoize(l, r - 1, 0, colors);

    for (int i = l; i < r; i++) {
        if (colors[i] == colors[r]) {
            dp[l][r][residue] = max(dp[l][r][residue], memoize(l, i - 1, 0, colors) + memoize(i + 1, r, residue + 1, colors));
        }
    }

    return dp[l][r][residue];
}

int solve(int n, vector<char> colors) {
    return memoize(0, n - 1, 0, colors);
}

int main() {
    int n;
    cin >> n;
    vector<char> colors(n);
    for (int i = 0; i < n; i++) {
        cin >> colors[i];
    }
    cout << solve(n, colors);
    return 0;
}

Crayon box โœ…
๐Ÿ‘1
from bisect import bisect_left, bisect_right
def frogs(X, S, Y):
    Y.sort()
    results = []
    for x, s in zip(X, S):
        left_bound = x - s
        right_bound = x + s
        left_index = bisect_left(Y, left_bound)
        right_index = bisect_right(Y, right_bound)
        num_flies = right_index - left_index
        results.append(num_flies)
    return results
๐Ÿ“ŒHiring Alert ๐Ÿšจ
WNS is inviting applications for Inventory Management Role !!

Eligibility Criteria & Requirements:

- Qualifications: Bachelor's in Commerce /
   Master's in Commerce Only

0-2 Years of experience .
Candidate should be comfortable in working from office and night shift.
Candidate should be proficient in English communication.

Work location- Sec 30, Gurugram, Haryana

Interested candidates can share their Raj.kumar@wns.com

โ€œIMMEDIATE JOINERS PREFDEREDโ€

Please share details :

Total Experience:
Current CTC:
Notice Period:
Okay with Night shift :
Accenture Bulk Hiring .

Customer Support Associate - UK & US Clients.

Hiring 300 candidates for Accenture Bengaluru, Mumbai and Delhi NCR offices

Any Batch , Any degree is eligible

Package is 3.5-6.5 Lpa

Apply link :-
https://bit.ly/3yr52zo

Guys Donโ€™t miss the opportunity.
๐Ÿ‘1
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    long long a, b;
    cin >> a;
    vector<long long> n(a);
    for (long long i = 0; i < a; ++i)
    cin >> n[i];
    cin >> b;
    vector<long long> r(b);
    for (long long i = 0; i < b; ++i)
        cin >> r[i];
    vector<long long> d(r.begin(), r.begin() + a);
    d.insert(d.end(), r.begin(), r.end());
    vector<long long> initial_diff;
    initial_diff.reserve(a);
    for (long long i = 0; i < a; ++i)
    initial_diff.push_back(abs(n[i] - d[i]));
    if (all_of(initial_diff.begin() + 1, initial_diff.end(), &
    {
        return x == initial_diff[0]; }))
    {
        cout << initial_diff[0] << endl;
    }
    else
    {
        for (long long i = 1; i < b; ++i) {
            vector<long long> window(d.begin() + i, d.begin() + i + a);
            vector<long long> diff;
            diff.reserve(a);
            transform(n.begin(), n.end(), window.begin(), back_inserter(diff), [](long long x, long long y)
            {
            return abs(x - y); });
            if (all_of(diff.begin() + 1, diff.end(), &
            {
                return x == diff[0]; }))
                {
                cout << diff[0] << endl;
                break;
            }
        }
    }
    return 0;
}

Morgan Stanley โœ