๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
9.63K subscribers
5.59K photos
3 videos
95 files
10.2K 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
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int MOD = 1000000007;
int countNewArrays(vector<int>& arr) {
    int n = arr.size();
        sort(arr.begin(), arr.end());
    long long result = 1;
    for (int i = 0; i < n; ++i) {
        int a = arr[i] - i;
                if (a <= 0) {
            return 0;
                }
        result = (result * possaible_values) % MOD;
    }
   
    return result;
}

DE SHAW โœ…
๐Ÿ‘1
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
typedef struct {
    int a, b, c;
    double area;
} triangle;

double calculate_area(int a, int b, int c) {
    double p = (a + b + c) / 2.0;
    return (p * (p - a) * (p - b) * (p - c));
}

int compare(const void* a, const void* b) {
    triangle* t1 = (triangle*)a;
    triangle* t2 = (triangle*)b;
    if (t1->area < t2->area)
        return -1;
    else if (t1->area > t2->area)
        return 1;
    else
        return 0;
}

int sort_by_area(triangle* tr, int n) {

    if (tr == NULL || n <= 0) {
        return -1;
    }
        for (int i = 0; i < n; i++) {
        tr[i].area = calculate_area(tr[i].a, tr[i].b, tr[i].c);
    }
        qsort(tr, n, sizeof(triangle), compare);
   
    return 0;
}


IBMโœ…
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
public class Main {

    public static void convertToIpv6(String ipv4Address) {
        String[] octets = ipv4Address.split("\\.");
        if (octets.length != 4) {
            System.out.println("Invalid input");
            return;
        }

        if (octets[0].equals("127")) {
            System.out.println("::1");
            return;
        }

        StringBuilder ipv6 = new StringBuilder("::FFFF:");

        try {
            for (int i = 0; i < 4; i++) {
                int octet = Integer.parseInt(octets[i]);
                if (octet < 0 || octet > 255) {
                    System.out.println("Invalid input");
                    return;
                }
                String hex = String.format("%02X", octet);
                ipv6.append(hex);
                if (i == 1) {
                    ipv6.append(":");
                }
            }
        } catch (NumberFormatException e) {
            System.out.println("Invalid input");
            return;
        }

        System.out.println(ipv6.toString());
    }


IBMโœ…
def optimize_packaging(N, prods, M, bxs, K):
    prods.sort(key=lambda x: x[0], reverse=True)
    bxs.sort(key=lambda x: x[0], reverse=True)
   
    boxC = 0
    pidx = 0
   
    for bx in bxs:
        boxW, boxV = bx
        currW = 0
        currV = 0
       
        while (pidx < N and
               currW + prods[pidx][0] <= boxW and
               currV + prods[pidx][1] <= boxV):
            currW += prods[pidx][0]
            currV += prods[pidx][1]
            pidx += 1
       
        if currW > 0 or currV > 0:
            boxC += 1
       
        if pidx == N:
            break
   
    return boxC if pidx == N and boxC <= K else -1


Product Packaging
Meesho Dice โœ…
def last_animal_name_length(animal_sequence):
    print(animal_sequence)
    res = [an for an in animal_sequence.split('-') if an != '']
    l=res[-1]
    if(l=='|'):return 3
    return len(l)



IBMโœ…
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main() {
    fast();
    int N, M, K;
    cin >> N >> M; 

    unordered_map<int, int> freq;

    for (int i = 0; i < N; i++) {
        set<int> uniqP;
        for (int j = 0; j < M; j++) {
            int pid;
            cin >> pid;
            uniqP.insert(pid);
        }
        for (int prod : uniqP) {
            freq[prod]++;
        }
    }

    cin >> K; 

    vector<int> res; 
    for (auto& it : freq) {
        if (it.second >= K) {
            res.push_back(it.first);
        }
    }
    sort(res.begin(), res.end());

    for (int prod : res) {
        cout << prod << " ";
    }
    cout << endl;

}
๐Ÿ‘2
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
def parse_ip_header(a, b, c):
    def binary_to_decimal(binary_str):
        try:
            return int(binary_str, 2)
        except ValueError:
            print("Error converting binary to decimal. Invalid binary string.")
            return -1
    if len(a) < 32 or len(b) < 32 or len(c) < 32:
        print("INVALID Input")
        return
    version = binary_to_decimal(a[0:4])
    protocol_binary = a[4:12]
    ttl_binary = a[12:20]
    packet_length_binary = a[20:32]
    protocol_number = binary_to_decimal(protocol_binary)
    protocol = 'TCP' if protocol_number == 6 else 'UDP' if protocol_number == 17 else 'Unknown'
    ttl = binary_to_decimal(ttl_binary)
    packet_length = binary_to_decimal(packet_length_binary)
   
    def binary_ip_to_decimal(ip_binary):
        try:
            return '.'.join(str(binary_to_decimal(ip_binary[i:i+8])) for i in range(0, 32, 8))
        except ValueError:
            print("Error converting binary IP to decimal.")
            return "Invalid IP"
    source_ip = binary_ip_to_decimal(b)
    destination_ip = binary_ip_to_decimal(c)
    print(f"{version},{protocol},{ttl},{packet_length}")
    print(source_ip)
    print(destination_ip)

import sys

n = int(input())
inputs = [line.strip() for line in sys.stdin.readlines()]

if len(inputs) < 3:
    print("Invalid Input")
else:
    a, b, c = inputs[:3]
    parse_ip_header(a, b, c)


IBMโœ