๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
9.52K subscribers
5.55K photos
3 videos
95 files
9.64K 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
SELECT product_name, cost AS product_cost, category AS product_category
FROM products AS p1
WHERE cost = (
    SELECT MAX(cost)
    FROM products AS p2
    WHERE p1.category = p2.category
)
ORDER BY product_cost DESC, product_name ASC;

Fractalโœ…
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
public static int countHashtagDivisors(String description1, String description2) {
        int len1 = description1.length();
        int len2 = description2.length();
        int gcdLength = gcd(len1, len2);
       
        int commonDivisors = 0;
        for (int i = 1; i <= gcdLength; i++) {
            if (gcdLength % i == 0) {
                String candidate = description1.substring(0, i);
                if (isValidDivisor(description1, candidate) && isValidDivisor(description2, candidate)) {
                    commonDivisors++;
                }
            }
        }
        return commonDivisors;
    }

    public static int gcd(int a, int b) {
        while (b != 0) {
            int temp = b;
            b = a % b;
            a = temp;
        }
        return a;
    }

    public static boolean isValidDivisor(String description, String candidate) {
        int len = description.length();
        int candLen = candidate.length();
        if (len % candLen != 0) return false;
       
        StringBuilder repeated = new StringBuilder();
        for (int i = 0; i < len / candLen; i++) {
            repeated.append(candidate);
        }
        return repeated.toString().equals(description);
    }

Hashtag divisor count โœ…
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>
#include <cctype>

using namespace std;
string sanitize(string s) {
    string result;
    for (char c : s) {
        if (isalnum(c)) { 
            result += tolower(c); 
        }
    }
    return result;
}

vector<string> generate_usernames(vector<string> names) {
    unordered_map<string, int> username_count; 
    vector<string> usernames;
   
    for (string full_name : names) {
        vector<string> words;
        string word;
        for (char c : full_name) {
            if (c == ' ') {
                if (!word.empty()) words.push_back(word);
                word = "";
            } else {
                word += c;
            }
        }
        if (!word.empty()) words.push_back(word);
                string given_name = sanitize(words[0]);
        string family_name = sanitize(words.back());
                string username = family_name.substr(0, min(7, (int)family_name.length()));
        int remaining_len = 8 - username.length();
       
        if (remaining_len > 0) {
            username += given_name.substr(0, min(remaining_len, (int)given_name.length()));
        }
                string final_username = username;
        int counter = 1;
       
        while (username_count.find(final_username) != username_count.end()) {
            if (final_username.length() < 8) {
                final_username = username + to_string(counter);
            } else {
                final_username = username.substr(0, 7) + to_string(counter);
            }
            counter++;
        }
                username_count[final_username]++;
        usernames.push_back(final_username);
    }
   
    return usernames;
}



Company Username โœ…
Squarepoint
public static int solution(int[] objects, int radius) {
        int n = objects.length;
        int maxIlluminated = 0;
        int bestPosition = Integer.MAX_VALUE;
        int left = 0;

        for (int right = 0; right < n; right++) {
            while (objects[right] - objects[left] > 2 * radius) {
                left++;
            }

            int count = right - left + 1;

            int candidatePosition = objects[right] - radius;
            candidatePosition = Math.max(candidatePosition, objects[left]);

            if (count > maxIlluminated) {
                maxIlluminated = count;
                bestPosition = candidatePosition;
            } else if (count == maxIlluminated) {
                bestPosition = Math.min(bestPosition, candidatePosition);
            }
        }

        return bestPosition;
    }

Coinbase (FTE) โœ…
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
Python
from typing import List
from collections import defaultdict

def parseNetworkChargebackInfo(rows: List[str]) -> List[str]:
    currency_conversion = {
        'EUR': 100, 'USD': 100, 'SGD': 100, 'BRL': 100,
        'JPY': 1, 'ISK': 1, 'KRW': 1, 'CAD': 100
    }

    valid_disputes = []
    withdrawn_disputes = defaultdict(dict)
    transaction_dates = {}

    for file_data in rows:
        lines = file_data.split('\n')
        file_info = lines[0].split('.')[0]
        network, date = file_info.split('_')
        headers = lines[1].split(',')
       
        field_indices = {field: headers.index(field) for field in
                         ['transaction', 'merchant', 'amount', 'currency', 'evidence_due_by', 'reason']}

        for line in lines[2:]:
            fields = line.split(',')
            if len(fields) < len(headers):
                continue

            transaction_id = fields[field_indices['transaction']]
            reason = fields[field_indices['reason']]
           
            try:
                amount = int(float(fields[field_indices['amount']]))
                currency = fields[field_indices['currency']]
                evidence_due_by = int(fields[field_indices['evidence_due_by']])
               
                if currency not in currency_conversion or amount < 0 or evidence_due_by < 0:
                    continue
            except (ValueError, KeyError):
                continue

            dispute_id = f"{network}{transaction_id}"
            merchant_id = fields[field_indices['merchant']]
            major_amount = amount / currency_conversion[currency]
            formatted_value = f"{major_amount:.2f}{currency}"

            if reason == 'withdrawn':
                withdrawn_disputes[network][transaction_id] = date
            else:
                valid_disputes.append((dispute_id, merchant_id, formatted_value, evidence_due_by, date))
           
            transaction_dates[transaction_id] = date

    output = []
    for dispute in valid_disputes:
        dispute_id, merchant_id, value, due_by, date = dispute
        network, transaction_id = dispute_id[:4], dispute_id[4:]
       
        if transaction_id in withdrawn_disputes[network]:
            if withdrawn_disputes[network][transaction_id] >= date:
                continue
       
        output.append(f"{dispute_id},{merchant_id},{value},{due_by}")

    return sorted(output)

# Sample test case
rows = [
    "VISA_20230601.csv\n"
    "transaction,merchant,amount,currency,evidence_due_by,reason\n"
    "123890132,47821,37906,USD,1686812400,fraudulent\n"
    "110450953,63724,12750,JPY,1686898800,duplicate\n",
    "JCB_20230604.csv\n"
    "transaction,merchant,currency,amount,evidence_due_by,reason\n"
    "110450953,11000,SGD,15000,1686898820,duplicate"
]

output = parseNetworkChargebackInfo(rows)
for line in output:
    print(line)


Stripe โœ…
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
def max_frame_sum(matrix, frameSize):
    n, m = len(matrix), len(matrix[0])
    max_sum = -1
    elems = set()
   
    for i in range(n - frameSize + 1):
        for j in range(m - frameSize + 1):
            s = 0
            s += sum(matrix[i][j:j+frameSize]) + sum(matrix[i+frameSize-1][j:j+frameSize])
            for k in range(i+1, i+frameSize-1):
                s += matrix[k][j] + matrix[k][j+frameSize-1]
            if s > max_sum:
                max_sum = s
                elems = set()
                elems.update(matrix[i][j:j+frameSize])
                elems.update(matrix[i+frameSize-1][j:j+frameSize])
                for k in range(i+1, i+frameSize-1):
                    elems.add(matrix[k][j])
                    elems.add(matrix[k][j+frameSize-1])
            elif s == max_sum:
                elems.update(matrix[i][j:j+frameSize])
                elems.update(matrix[i+frameSize-1][j:j+frameSize])
                for k in range(i+1, i+frameSize-1):
                    elems.add(matrix[k][j])
                    elems.add(matrix[k][j+frameSize-1])
   
    return sum(elems)


Coinbase(FTE)โœ…
9 hacks to boost your productivity:

1) Plan your day. Write everything on a physical paper.

2) Follow the 80/20 rule. 20% of your work will bring you 80% of the results.

3) Stop multitasking. Switching tasks significantly reduces your productivity.

4) Remove all distractions from your working environment.

5) When tried, take a nap.

6) Learn to say no, you will never have enough time if you say "yes" to everything.

7) Anything that can be done under 5 minutes. Do it at that instant.

8) Do that task that you hate first.

9) Set deadlines; the task will never be finished without deadlines.