๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
9.62K subscribers
5.6K photos
3 videos
95 files
10.4K 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
Hey everyone, Matiks is growing faster, faster than we thought. Hence we are looking for individual contributors who can act as catalysts in our team. We are looking for 6 month Full-stack interns (React/ React-Native + GO) to join our team. Requirements:

1. Available for 6 month offline internship in our HSR Bangalore office.

2. Have created react-native apps in their previous internships/projects.

3. Having experience in Go would be an add on. 4. No restriction on college, if you have relevant work experience and have done quality work in past. Please reach out to me.

Benefits:

1. Stipend of 50K per month

2. Chance to get full time opportunity at Matiks

3. Chance to  create a platform that will be used by Millions of users.

If you are someone who have experience in and react-native then please DM me or send your resume on mohan@matiks.com. We are open for both 6 month internship and Full time offer.
๐Ÿ‘2
#include <bits/stdc++.h>
using namespace std;
string makeLexicographicallySmallestPalindrome(string s) {
    int n = s.length();
    unordered_map<char, int> a;
    string b;
    for (char c : s) {
        a[c]++;
    }
    for (char c = 'a'; c <= 'z'; c++) {
        if (a[c] % 2 != 0) {
            b += c;
        }
    }
    int m = b.length();
    int p = 0;
    for (int i = m - 1; i >= m / 2; i--) {
        char x = b[i];
        char y = b[p];
        a[x]--;
        b[i] = y;
        a[y]++;
        p++;
    }

    string c, d, e;
    for (char c1 = 'a'; c1 <= 'z'; c1++) {
        int f = a[c1];
        if (f != 0) {
            if (f % 2 == 0) {
                c += string(f / 2, c1);
            } else {
                c += string((f - 1) / 2, c1);
                d += c1;
            }
        }
    }
    e = c;
    reverse(e.begin(), e.end());
    return c + d + e;
}
int main() {
    string s;
    cin >> s;
    cout <<makeLexicographicallySmallestPalindrome(s) << endl;
    return 0;
}
#include <bits/stdc++.h>
using namespace std;
string all_happy(int a, int b, vector<int> c) {
    vector<int> d = c;
    sort(d.begin(), d.end());
   
    int e = 0;
    vector<int> f(a + 1, 0);
   
    auto g = [&](int h, int i) {
        for (; h <= a; h += h & -h) {
            f[h] += i;
        }
    };
   
    auto j = [&](int h) {
        int k = 0;
        for (; h > 0; h -= h & -h) {
            k += f[h];
        }
        return k;
    };

    for (int l = 0; l < a; ++l) {
        int m = lower_bound(d.begin(), d.end(), c[l]) - d.begin() + 1;
        e += j(a) - j(m);
        g(m, 1);
    }

    if (e == 0) return "YES";
   
    if (b == 0 || e % b != 0) return "NO";
   
   
    return e / b > 0 ? "YES" : "NO";
}


Make them happy โœ…
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
#include <bits/stdc++.h>
using namespace std;
void bfs(int a, vector<vector<int>>& b, vector<bool>& c) {
    queue<int> d;
    d.push(a);
    c[a] = true;
    while (!d.empty()) {
    int e = d.front();
    d.pop();
    for (int f = 0; f < b.size(); ++f) {
    if (b[e][f] == 1 && !c[f]) {
    c[f] = true;
    d.push(f);
            }
        }
    }
}
int solve(int a, int b, vector<vector<int>>& c, vector<int>& d) {
    int e = INT_MAX, f = -1;
    for (int g : d) {
    vector<bool> h(a, false);
    vector<vector<int>> i = c;
    for (int j = 0; j < a; ++j) {
    i[g][j] = 0;
    i[j][g] = 0;
    }
    int k = 0;
    for (int l : d)
    {
    if (!h[l]) {
    bfs(l, i, h);
    }
    }
    k = count(h.begin(), h.end(), true);
    if (k < e || (k == e && g < f))
    {
    e = k;
    f = g;
    }
    }
    return f;
}

int main() {
    int a, b;
    cin >> a >> b;
    vector<vector<int>> c(a, vector<int>(a));
    for (int d = 0; d < a; ++d) {
    for (int e = 0; e < a; ++e)
    {
            cin >> c[d][e];
    }
    }
    vector<int> d(b);
    for (int e = 0; e < b; ++e)
    {
    cin >> d[e];
    }
    cout << solve(a, b, c, d) << endl;
    return 0;
}

Reduce the damage
Zeta โœ…
โค1
import math
def solve(l, r):
    count = 0
    for x in range(l, r + 1):
        sqrt_x = math.isqrt(x)
        if x % sqrt_x == 0: 
            count += 1
    return count

Lucky number โœ…
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
class CommunicationException(Exception):
    def __init__(self, message):
        super().__init__(message)

class Caller:
    def __init__(self, name):
        self.name = name

class CommsHandlerABC:
    def connect(self, user1, user2):
        pass

    def hangup(self, user1, user2):
        pass

    def clear_all(self):
        pass

class CommsHandler(CommsHandlerABC):
    def __init__(self, users):
        self.connected_users = set()
        self.user_objects = [Caller(user) for user in users]

    def connect(self, user1_idx, user2_idx) -> str:
        user1 = self.user_objects[user1_idx]
        user2 = self.user_objects[user2_idx]

        if user1.name == user2.name:
            raise CommunicationException(f"{user1.name} cannot connect with {user2.name}")

        if self.is_line_in_use():
            raise CommunicationException("Connection in use. Please try later")

        connection = frozenset([user1.name, user2.name])
        if connection in self.connected_users:
            raise CommunicationException(f"Connection between {user1.name} and {user2.name} already exists")

        self.connected_users.add(connection)
        return f"Success: Connection established between {user1.name} and {user2.name} "

    def hangup(self, user1_idx, user2_idx) -> str:
        user1 = self.user_objects[user1_idx]
        user2 = self.user_objects[user2_idx]

        if user1.name == user2.name:
            raise CommunicationException(f"{user1.name} cannot hangup with {user2.name}")

        connection = frozenset([user1.name, user2.name]) 
        if connection in self.connected_users:
            self.connected_users.remove(connection)
            return f"Success: {user1.name} and {user2.name} are disconnected "
        else:
            raise CommunicationException(f"{user1.name} and {user2.name} not found in the communication channel")

    def clear_all(self):
        self.connected_users.clear()

    def is_line_in_use(self) -> bool:
        return len(self.connected_users) >= 2


MSCI โœ…
def FilledBuckets(N, queries):
    filled = False
    clear_even = False
    clear_odd = False

    for query in queries:
        if query == 1:
            filled = True
            clear_even = False
            clear_odd = False
        elif query == 2 and filled:
            clear_even = True
        elif query == 3 and filled:
            clear_odd = True
        elif query == 4:
            filled = False
            clear_even = False
            clear_odd = False

    if not filled:
        return 0

    result = N
    if clear_even:
        result -= N // 2
    if clear_odd:
        result -= (N + 1) // 2
    return result

Fractal โœ…
def sp(K, L, R):
    MOD = 93179
    MAX = 20000
    is_p = [True] * (MAX + 1)
    is_p[0] = is_p[1] = False
    for i in range(2, int(MAX**0.5) + 1):
        if is_p[i]:
            for j in range(i * i, MAX + 1, i):
                is_p[j] = False

    sp_primes = [1] * (MAX + 1)
    for i in range(2, MAX + 1):
        if is_p[i]:
            d_sum = sum(int(d) for d in str(i))
            if d_sum % K == 0:
                sp_primes[i] = i
            else:
                sp_primes[i] = 1
        else:
            sp_primes[i] = 1

    prf = [1] * (MAX + 1)
    for i in range(1, MAX + 1):
        prf[i] = (prf[i - 1] * sp_primes[i]) % MOD

    res = []
    for l, r in zip(L, R):
        if l > 1:
            p = (prf[r] * pow(prf[l - 1], MOD - 2, MOD)) % MOD
        else:
            p = prf[r]
        res.append(p if p > 1 else 1)

    return res


Tengen and numbers โœ