๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
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
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
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 โœ…
#include <iostream>
#include <string>

using namespace std;

string getNextSequence(const string &s) {
    string result = "";
    int count = 1;
   
    for (size_t i = 1; i <= s.length(); ++i) {
        if (i < s.length() && s[i] == s[i - 1]) {
            ++count;
        } else {
            result += to_string(count) + s[i - 1];
            count = 1;
        }
    }
   
    return result;
}

string getNthPasscode(long long n) {
    if (n == 1) {
        return "1";
    }

    string result = "1";
    for (long long i = 2; i <= n; ++i) {
        result = getNextSequence(result);
    }
   
    return result;
}

int main() {
    long long smartCardNumber;
    cin >> smartCardNumber;
   
    string passcode = getNthPasscode(smartCardNumber);
    cout << passcode << endl;
   
    return 0;
}

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

using namespace std;

long long findTeaserLevels(vector<long long>& levelValues, long long threshold) {
    sort(levelValues.begin(), levelValues.end());
    long long closestSum = LLONG_MIN;

    for (size_t i = 0; i < levelValues.size() - 2; ++i) {
        size_t left = i + 1;
        size_t right = levelValues.size() - 1;

        while (left < right) {
            long long currentSum = levelValues[i] + levelValues[left] + levelValues[right];

            if (currentSum <= threshold) {
                if (currentSum > closestSum) {
                    closestSum = currentSum;
                }
                ++left;
            } else {
                --right;
            }
        }
    }

    return closestSum == LLONG_MIN ? -1 : closestSum;
}

int main() {
    int levelValuesSize;
    cin >> levelValuesSize;

    vector<long long> levelValues(levelValuesSize);
    for (int i = 0; i < levelValuesSize; ++i) {
        cin >> levelValues[i];
    }

    long long thresholdValue;
    cin >> thresholdValue;

    long long result = findTeaserLevels(levelValues, thresholdValue);
    if (result == -1) {
        cout << "NA" << endl;
    } else {
        cout << result << endl;
    }

    return 0;
}

Morgan Stanley โœ…
Wipro is Inviting applications of (Analyst) for Gurgaon office.
Candidates with an experience range of 0 - 1 yr. Only, comfortable with US shifts, can send their CV's to ayaan.hossain@wipro.com with the below details.

Role- Analyst
Desired Candidate Profile:
Should be flexible working in Shifts.
Experience- 0 yrs. to 1 yrs.
Qualification- MBA/M.com/ B.com/BBA.
Location- Gurgaon (Work From Office Only)
Looking for Immediate Joiners
Genpact is hiring !

Skill set- P&C Insurance
Experience - 0-3 years (Freshers can Apply)
Location - Noida
Shift- APAC shift
Qualification - Any except technical

GOOD COMMUNICATION REQUIRED.

Note- Interested candidate can share their CV at rangoli.bhatt@genpact.com with the subject line "Application for Insurance "
int countSetBits(int n) {
    int count = 0;
    while (n) {
        count += n & 1;
        n >>= 1;
    }
    return count;
}

int countSubsetsWithSumSetBitsEqualToK(const vector<int>& arr, int k) {
    int n = arr.size();
    int subsetCount = 0;
    int totalSubsets = 1 << n;

    for (int i = 0; i < totalSubsets; ++i) {
        int subsetSum = 0;
        for (int j = 0; j < n; ++j) {
            if (i & (1 << j)) {
                subsetSum += arr[j];
            }
        }
        if (countSetBits(subsetSum) == k) {
            ++subsetCount;
        }
    }

    return subsetCount;
}

Hack on Amazon โœ…
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

int calculate_operations(std::vector<int>& arr, int target) {
    int operations = 0;
    for (int num : arr) {
        operations += std::abs(num - target);
    }
    return operations;
}

int main() {
    int N;
    std::cin >> N;
    std::vector<int> A(N);
   
    for (int i = 0; i < N; ++i) {
        std::cin >> A[i];
    }

    std::sort(A.begin(), A.end());
        int median = A[N / 2];
  
    int min_operations = calculate_operations(A, median);

    for (int i = 0; i < N; ++i) {
        int original_value = A[i];
        A[i] = median;
        int operations_with_free_move = calculate_operations(A, median);
        min_operations = std::min(min_operations, operations_with_free_move);
        A[i] = original_value;
    }

    std::cout << min_operations << std::endl;

    return 0;
}

Hack on Amazon โœ…
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
#include <iostream>
#include <vector>
using namespace std;
struct Edge {
    int to;
    bool visited;
};
void dfs(int node, vector<vector<Edge>>& tree, vector<bool>& visited) {
    visited[node] = true;
    for (auto& edge : tree[node]) {
        if (!visited[edge.to]) {
            if (!edge.visited) {
                edge.visited = true;
                for (auto& reverseEdge : tree[edge.to]) {
                    if (reverseEdge.to == node) {
                        reverseEdge.visited = true;
                        break;
                    }
                }
                dfs(edge.to, tree, visited);
            }
        }
    }
}
int main() {
    int N;
    cin >> N;
   
    vector<vector<Edge>> tree(N + 1);
    for (int i = 0; i < N - 1; ++i) {
        int u, v, c;
        cin >> u >> v >> c;
        tree[u].push_back({v, c == 1});
        tree[v].push_back({u, c == 1});
    }
    vector<bool> visited(N + 1, false);
    int carCount = 0;
    for (int i = 2; i <= N; ++i) {
        if (!visited[i]) {
            for (auto& edge : tree[i]) {
                if (edge.to == 1 && !edge.visited) {
                    edge.visited = true;
                    for (auto& reverseEdge : tree[1]) {
                        if (reverseEdge.to == i) {
                            reverseEdge.visited = true;
                            break;
                        }
                    }
                    carCount++;
                    dfs(i, tree, visited);
                    break;
                }
            }
        }
    }
    cout << carCount << endl;

    return 0;
}

Hack on Amazon โœ…
๐Ÿ‘1
Free Certification Courses

1) JavaScript Fundamentals
2) SQL
3) Git and GitHub
4) HTML and CSS
5) Basic projects
6) OOPs (Newly added)

This are the 5 courses which are available for free, and when you will join corporate this are the basic requirements.

Link: https://bit.ly/4avpEUz

Limited time ke liye hai, enroll as soon as possible (Isse pehle paid krde) ๐Ÿคž๐Ÿคž
int x(vector<int>& nums){
    int cnt=1;
    for(int i=0; i<nums.size()-1; i++){
        if(nums[i]>nums[i+1]){
            cnt++;
        }
    }
    return cnt;
}

Hack on Amazon โœ…
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main(){
    // int t;
    // cin >> t;
    // while(t--){
    int n ;
    cin >> n ;
    vector<int> vec(n);
    for(int i = 0 ;i < n ; ++i){
        cin >> vec[i];
    }
    sort(vec.begin(),vec.end());
    for(auto it : vec)
        cout << it << " ";
    cout << "\n";
    // }
}


Hack on Amazon โœ…
#include <iostream>
using namespace std;

int main() {
    int N;
    cin >> N;

    int totalCoins = 0;
    int i = 1;
    while (true) {
        int coins = N / i;
        if (coins < 1) {
            break;
        }
        totalCoins += coins;
        i++;
    }

    cout << totalCoins << endl;

    return 0;
}

Hack on Amazon โœ…
๐Ÿ‘1
#include <iostream>

using namespace std;

const int MOD = 1e9 + 7;

long long binomialCoefficient(int n, int k) {
    if (k > n - k) {
        k = n - k;
    }
    long long res = 1;
    for (int i = 0; i < k; ++i) {
        res = (res * (n - i)) % MOD;
        res /= (i + 1);
    }
    return res % MOD;
}

int countDistinctSequences(int x, int y) {
    return binomialCoefficient(y - 1, x - 1);
}

int main() {
    int x, y;
    cin >> x >> y;

    int result = countDistinctSequences(x, y);
    cout << result << endl;

    return 0;
}

Hacks on Amazon โœ…
๐Ÿ‘2