allcoding1
27.7K subscribers
2.2K photos
2 videos
74 files
851 links
Download Telegram
def max_call_executives(n, start_times, end_times):
    timeline = [0] * (24 * 60 + 1)
   
    for i in range(n):
        start = int(start_times[i][:2]) * 60 + int(start_times[i][2:])
        end = int(end_times[i][:2]) * 60 + int(end_times[i][2:])
        timeline[start] += 1
        timeline[end] -= 1
   
    max_executives = 0
    current_executives = 0
    for i in range(len(timeline)):
        current_executives += timeline[i]
        max_executives = max(max_executives, current_executives)
   
    return max_executives

Call Centre

@allcoding1
👍1
Lexicographical smallest substring - IBM

@allcoding1
Salesperson ID's - IBM
@allcoding1
#include<stdio.h>
#include<stdlib.h>

int compare(const void *a, const void *b) {
    return (*(int*)a - *(int*)b);
}

int main() {
    int N;
    scanf("%d", &N);

    if (N <= 1) {
        printf("NO HOURS\n");
        return 0;
    }

    int *A = (int*)malloc(N * sizeof(int));

    for (int i = 0; i < N; i++) {
        scanf("%d", &A[i]);
    }

    qsort(A, N, sizeof(int), compare);

    int count = 0;

    for (int i = 0; i < N - 1; i++) {
        for (int j = i + 1; j < N; j++) {
            if ((A[i] + A[j]) % 60 == 0) {
                count = (count + 1) % MOD;
            }
        }
    }

    if (count > 0) {
        printf("%d\n", count);
    } else {
        printf("NO HOURS\n");
    }

    free(A);

    return 0;
}

Hours Count

Telegram:- @allcoding1
👍6🔥1
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

class Solution {
public:
    int maxSumOptimalArrangement(vector<int>& coins) {
        vector<int> positive;
        vector<int> negative;

        for (int coin : coins) {
            if (coin >= 0)
                positive.push_back(coin);
            else
                negative.push_back(coin);
        }

        sort(positive.rbegin(), positive.rend());
       
        sort(negative.begin(), negative.end());

        int totalSum = 0;

        for (size_t i = 0; i < max(positive.size(), negative.size()); ++i) {
            if (i < positive.size())
                totalSum += positive[i];
            if (i < negative.size())
                totalSum -= negative[i];
        }

        return totalSum;
    }
};

ZS campus beat code

Circuit Board

Telegram:- @allcoding1
👍3
👍2
allcoding1
Photo
#include<bits/stdc++.h>
using namespace std;

const int MOD = 1e9 + 7;
vector<vector<vector<string>>> dp;

vector<string> solve(string& alice, string& bob, int i, int j) {
    if(i == alice.size() || j == bob.size()) {
        return {""};
    }
    if(dp[i][j].size() != 0) {
        return dp[i][j];
    }
    if(alice[i] == bob[j]) {
        vector<string> tmp = solve(alice, bob, i+1, j+1);
        for(string& s : tmp) {
            s = alice[i] + s;
        }
        return dp[i][j] = tmp;
    }
    vector<string> left = solve(alice, bob, i+1, j);
    vector<string> right = solve(alice, bob, i, j+1);
    if(left[0].size() > right[0].size()) {
        return dp[i][j] = left;
    }
    if(left[0].size() < right[0].size()) {
        return dp[i][j] = right;
    }
    left.insert(left.end(), right.begin(), right.end());
    sort(left.begin(), left.end());
    left.erase(unique(left.begin(), left.end()), left.end());
    return dp[i][j] = left;
}

int main() {
    int T;
    cin >> T;
    while(T--) {
        string alice, bob;
        cin >> alice >> bob;
        dp = vector<vector<vector<string>>>(alice.size(), vector<vector<string>>(bob.size()));
        vector<string> trips = solve(alice, bob, 0, 0);
        for(string& trip : trips) {
            cout << trip << endl;
        }
    }
    return 0;
}

Telegram:- @allcoding1
👍2🎉1
Telegram:- @allcoding1
1👍1
Two friends problem

Telegram:- @allcoding1
int main()
{
    string text;
    getline(cin, text);

    int index = 0;

    while (index + 13 < text.length() && (index = text.rfind(" ", index + 13)) != string::npos) {
        text.replace(index, 1, "\n");
    }

    cout << text << endl;

    return 0;
}

INFA thon 4.0

Telegram:- @allcoding1
👍1
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define max_v 25
bool f(double A,double B,double a,double b)
{
    double d=sqrt(a*a+b*b);
    double a1=asin(A/d);
    double a2=asin(b/d)*2.0;
    double h=cos(a1-a2)*d;
    if(B>h)
        return true;
    else
        return false;
}
int main()
{
    int t;
    bool flag;
    cin >> t;
    while(t--)
    {
        double A,B,a,b;
        cin >> A >> B >> a >> b;
        if(A<B)
            swap(A,B);
        if(a<b)
            swap(a,b);
        if(A>a&&B>b)
        {
            flag=true;
        }
        else if(A*B<=a*b||b>=B)
        {
            flag=false;
        }else
        {
            flag=f(A,B,a,b);
        }
        if(flag)
        {
            cout << "Escape is possible." << endl;

        }else
        {
            cout << "Box cannot be dropped." << endl;

        }
    }
    return 0;
}

INFAthon 4.0

Telegram:- @allcoding1
👍3🔥1
Diverse Deputations
Python 3

Telegram:- @allcoding1
👍2
Accenture exam Answer 2/4/24
@allcoding1

1) I got sick, I have _

As) an

2) A) but everyone
B) government
C) an should
D) global..

As) DBAC


3) ocean : shallow
As) infinite

4) I comb my hair....

As) I used to

5) antonym word " ACCURATE "

As) invalid


6) Continue

As) prolong


7) we felt____missing the farewell party

As) didn't feel good

@allcoding1

8) horizontal bar represent

As) date input/output

9) charvi is the mother of sara...

As) sister in law


10) by the time we arrived they____ (to leave)

As) had left


11) 1) it is possible to determine....
2) no other mobile brand....

As) both conclusion follow



Telegram:- @allcoding1
👍10
F
Cat : feline