๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
9.6K subscribers
5.59K photos
3 videos
95 files
10.1K 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
int closestToTarget(vector<int> oxygenLevels, int target) {
    int n = oxygenLevels.size();
    int minDiff = abs(oxygenLevels[0] - target); // Initialize the minimum difference with the first oxygen level

    // Iterate through the oxygen levels to find the minimum difference
    for (int i = 1; i < n; i++) {
        int diff = abs(oxygenLevels[i] - target);
        minDiff = min(minDiff, diff);
    }

    return minDiff;
}

Optimum oxygen
Salesforce โœ…
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
#include <stdio.h>
#include <stdbool.h>
#include <string.h>

bool isConnected(char* A[], int start, int end, bool visited[]) {
    if (start == end) {
        return true; // If we reached the K-th string, all previous strings can be connected.
    }
   
    visited[start] = true;
    int end_letter = A[start][1];
   
    for (int i = 1; i < end; i++) {
        if (!visited[i] && A[i][0] == end_letter) {
            if (isConnected(A, i, end, visited)) {
                return true;
            }
        }
    }
   
    visited[start] = false; // Backtrack if the connection was not successful.
    return false;
}

char* solution(char* A[], int N) {
    char* result = (char*)malloc(N * sizeof(char));
    bool visited[N];
    memset(visited, false, N * sizeof(bool));
   
    for (int i = 0; i < N; i++) {
        if (isConnected(A, 0, i, visited)) {
            result[i] = '1';
        } else {
            result[i] = '0';
        }
    }
   
    return result;
}

int main() {
    char* A1[] = {"he", "II", "10", "el"};
    int N1 = 4;
    char* result1 = solution(A1, N1);
    printf("Result 1: %s\n", result1); // Output: "1001"
    free(result1);

    char* A2[] = {"ab", "ba", "bq"};
    int N2 = 3;
    char* result2 = solution(A2, N2);
    printf("Result 2: %s\n", result2); // Output: "111"
    free(result2);
   
    return 0;
}

Microsoft OAโœ…
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
int32_t main(){
    ll n,m;
    cin>>n>>m;
    vector<ll> a(n);
    vector<ll> b(m);
    vector<ll> pre(n+1);
    for(int i=0;i<n;i++){
        cin>>a[i];
        pre[i+1]=pre[i]+a[i];
    }
    for(int i=0;i<m;i++){
        cin>>b[i];
    }
    ll k=(1LL<<m)-1;
    ll dp[n+1][k+1];
    for(int i=0;i<=n;i++){
        for(int j=0;j<=k;j++){
            dp[i][j]=0;
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=0;j<=k;j++){
            dp[i][j]=max(dp[i][j],dp[i-1][j]);
            for(int l=0;l<m;l++){
                if((1LL<<l)&j){
                    //
                }
                else{
                    ll next=(1LL<<l)|j,idx=i+b[l]-1;
                    if(idx>=0 and idx<=n)
                    dp[idx][next]=max(dp[idx][next],dp[i-1][j]+pre[idx]-pre[i-1]);
                }
            }
        }
    }
    ll ans=0;
    for(int i=0;i<=n;i++){
        ans=max(dp[i][k],ans);
    }
    cout<<ans<<endl;
    return 0;
}

Seat Booking
Sprinklrโœ…
int HaxRevenue(struct Garage garages[], int n)
{
    if (garages == NULL)
        return -1;
    int ans = -1;
    for (int i = 0; i < n; i++)
    {
        int revenue = (100 * garages[i].bikes) + (250 * garages[i].cars) + (500 * garages[i].trucks);
        ans = (revenue > ans) ? revenue : ans;
    }
    return ans;
}


C++ code
Accenture โœ