๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
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
def countIntersections(startsAt, endsAt):
    n = len(startsAt)
    events = []
    for i in range(n):
        events.append((startsAt[i], 'start', i))
        events.append((endsAt[i], 'end', i))
    events.sort(key=lambda x: (x[0], x[1] == 'start'))
    ans = [0] * n
    aa = set()
    for pos, typ, idx in events:
        if typ == 'start':
            ans[idx] += len(aa)
            for active in aa:
                ans[active] += 1
            aa.add(idx)
        elif typ == 'end':
            aa.remove(idx)
    return ans


Atlassian 2โœ…
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
int pre = 0;
const int m = 1e9 + 7;

long long ncr(int n, int r)
{
    if (!pre)
    {
        pre = 1;
        dp[0][0] = 0;
        dp[1][0] = 1;
        dp[1][1] = 1;

        for (int i = 2; i <= 40; i++)
        {
            dp[i][0] = 1;
            for (int j = 1; j < i; j++)
            {
                dp[i][j] = dp[i - 1][j] + dp[i - 1][j - 1];
            }
            dp[i][i] = 1;
        }
    }
    return dp[n][r];
}

long long count(long long x)
{
    long long ans = 0;
    long long cnt = 0;
    long long len = 0;
    while (x > 0)
    {
        if (x & 1)
        {
            cnt++;
            ans += ncr(len, cnt);
        }
        len++;
        x >>= 1;
    }
    return ans;
}

unsigned int nextPowerOf2(unsigned int n)
{
    n--;
    n |= n >> 1;
    n |= n >> 2;
    n |= n >> 4;
    n |= n >> 8;
    n |= n >> 16;
    n++;
    return n;
}

int solve(int n)
{
    int fn = nextPowerOf2(n) - 1;
    int bc = __builtin_popcount(n);
    int ans = count(n);
    for (int i = n + 1; i < fn; i++)
    {
        if (__builtin_popcount(i) == bc)
            ans = (ans + 1) % m;
    }
    return ans;
}
 

Atlassian 1โœ…
๐Ÿ˜ฑ1
def highest_two_digit_number(cards):
    cards.sort(reverse=True)
    return cards[0] * 10 + cards[1]

your_cards = list(map(int, input().strip().split()))
opponent_cards = list(map(int, input().strip().split()))

your_max = highest_two_digit_number(your_cards)
opponent_max = highest_two_digit_number(opponent_cards)
result = "true" if your_max > opponent_max else "false"
print(your_max)
print(opponent_max)
print(result)

Goldman Sachs
Try card โœ…
def minConnections(userConnections):
    def find(x):
        if parent[x] != x:
            parent[x] = find(parent[x])
        return parent[x]
   
    def union(x, y):
        px, py = find(x), find(y)
        if px != py:
            parent[px] = py
            return 1
        return 0
   
    users = set()
    for connection in userConnections:
        users.update(connection)
   
    parent = {user: user for user in users}
    components = len(users)
   
    for u, v in userConnections:
        components -= union(u, v)
   
    return components - 1
def identifyTheColorSheets(N, M, paintingSheet, shotCoordinates):
    color_count = [set() for _ in range(N)] 
    for x, y, color in shotCoordinates:
        for i, (P1, Q1, R1, S1) in enumerate(paintingSheet):
            if P1 <= x <= R1 and Q1 <= y <= S1:
                color_count[i].add(color)
    return [len(colors) for colors in color_count]

def main():
    N, M = map(int, input().split())
    paintingSheet = []
    for _ in range(N):
        paintingSheet.append(list(map(int, input().split())))
    shotCoordinates = []
    for _ in range(M):
        shotCoordinates.append(list(map(int, input().split())))
    result = identifyTheColorSheets(N, M, paintingSheet, shotCoordinates)
    for count in result:
        print(count)
if __name__ == "__main__":
    main()


Goldman Sachs
Colour โœ…
def is_modest(number):
    str_num = str(number)
    length = len(str_num)
    for i in range(1, length):
        left_part = int(str_num[:i])
        right_part = int(str_num[i:])

        if right_part != 0 and number % right_part == left_part:
            return True
    return False

def find_modest_numbers(M, N):
    modest_numbers = []
   
    for number in range(M, N + 1):
        if is_modest(number):
            modest_numbers.append(number)
   
    return modest_numbers

M, N = map(int, input().split())
modest_numbers = find_modest_numbers(M, N)
if modest_numbers:
    print(" ".join(map(str, modest_numbers)))
else:
    print("No modest numbers found within the range")

Goldman Sachs โœ