๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
9.63K subscribers
5.61K photos
3 videos
95 files
10.6K 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
class UserMainCode(object):

    @classmethod
    def strongString(cls, input1, input2):
        n = len(input2)
        min_strings = []

        for i in range(min(input1, n)):
            distribution = [''] * input1
            for j in range(n):
                distribution[j % input1] += input2[j]

            min_string = min(distribution)
            min_strings.append(min_string)

        result = max(min_strings)
        return result

Game of String Distribution โœ…
def profitable_project_pairs(profit, implementationCost):
    n = len(profit)
    net_profit = [profit[i] - implementationCost[i] for i in range(n)]
   
    net_profit.sort()
   
    count = 0
    left = 0
    right = n - 1
   
    while left < right:
        if net_profit[left] + net_profit[right] > 0:
            count += (right - left)
            right -= 1
        else:
            left += 1
   
    return count

Profitable project pairs โœ…
Workspan
๐Ÿ‘1
#include <iostream>
#include <vector>
using namespace std;
const int MOD = 10000007;
#define ll long long
#define vvll vector<vector<ll>>

vvll multiply(vvll& A, vvll& B ) {
    int n = A.size();
    vvll C(n, vector<ll>(n, 0));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            for (int k = 0; k < n; ++k) {
                C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % MOD;
            }
        }
    }
    return C;
}

vvll matrixExpo(vvll A, int power) {
    int n = A.size();
    vvll result(n, vector<ll>(n, 0));
    for (int i = 0; i < n; ++i) {
        result[i][i] = 1;
    }
    while (power > 0) {
        if (power % 2 == 1) {
            result = multiply(result, A);
        }
        A = multiply(A, A);
        power /= 2;
    }
    return result;
}

int solve(vector<int>& input) {
    int a = input[0], b = input[1], c = input[2], d = input[3], e = input[4], f = input[5], N = input[6];
   
    if (N <= 1) return 1;

    vvll T = {
        {a, b, 0, 0, 0, 0},
        {1, 0, 0, 0, 0, 0},
        {0, 0, c, d, 0, 0},
        {0, 0, 1, 0, 0, 0},
        {0, 0, 0, 0, e, f},
        {0, 0, 0, 1, 0, 0}
    };

  
    vector<ll> F = {1, 1, 1, 1, 1, 1};
   
    vvll T_power = matrixExpo(T, N - 1);

    ll result = 0;
    for (int i = 0; i < 6; ++i) {
        result = (result + T_power[0][i] * F[i]) % MOD;
    }

    return result;
}

int main() {
    vector<int> input = {1, 1, 1, 1, 1, 1, 3};
    cout << solve(input) << endl;
    return 0;
}


//linear recurrence ivp
๐Ÿ‘1
int balloonGame(int n, int input2[])
{
  int64_t dp[(1 << n)];
  memset(dp, 0x3f, sizeof(dp));
  dp[0] = 0;
  for (int i = 1; i < (1 << n); i++) {
    int x = __builtin_popcount(i);
    for (int j = 0; j < n; j++) {
      if (i & (1 << j)) {
int pv = i ^ (1 << j);
int64_t nx = dp[pv] + (input2[j] + (x-1)) / x;
dp[i] = min(dp[i], nx);
      }
    }
  }
  return dp[(1 << n) - 1];
}


Balloon Game โœ