๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
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
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int numDecodings(string msg) {
    int MOD = 1000000007;
    int n = msg.size();
   
    vector<long long> dp(n + 1, 0);
    dp[0] = 1;
   
    if (msg[0] == '0')
        dp[1] = 0;
    else if (msg[0] == '*')
        dp[1] = 9;
    else
        dp[1] = 1;
   
    for (int i = 2; i <= n; ++i) {
        if (msg[i - 1] == '0') {
           
            if (msg[i - 2] == '1' || msg[i - 2] == '2')
                dp[i] += dp[i - 2];
            else if (msg[i - 2] == '*')
                dp[i] += 2 * dp[i - 2];
        } else if (msg[i - 1] >= '1' && msg[i - 1] <= '9') {
     
            dp[i] += dp[i - 1];
           
            if (msg[i - 2] == '1' || (msg[i - 2] == '2' && msg[i - 1] <= '6'))
                dp[i] += dp[i - 2];
            else if (msg[i - 2] == '*') {
               
                if (msg[i - 1] <= '6')
                    dp[i] += 2 * dp[i - 2];
                else
                    dp[i] += dp[i - 2];
            }
        } else if (msg[i - 1] == '*') {
            dp[i] += 9 * dp[i - 1];
           
            if (msg[i - 2] == '1')
                dp[i] += 9 * dp[i - 2];
            else if (msg[i - 2] == '2')
                dp[i] += 6 * dp[i - 2];
            else if (msg[i - 2] == '*')
                dp[i] += 15 * dp[i - 2];
        }
       
        dp[i] %= MOD;
    }
   
    return dp[n];
}

Number of ways decode โœ…
def getPasswordStrength(passwords, common_words):
    result = []
    for password in passwords:
        is_weak = False
       
        if password.lower() in common_words:
            is_weak = True
        else:
            for word in common_words:
                if word.lower() in password.lower():
                    is_weak = True
                    break
       
        if password.isdigit():
            is_weak = True
       
        if password.islower() or password.isupper():
            is_weak = True
       
        if len(password) < 6:
            is_weak = True
       
        result.append("weak" if is_weak else "strong")
   
    return result

Password Validation โœ…
๐Ÿ‘1๐Ÿ˜ฑ1
def groupTransactions(transactions):
    counts = {}
    for item in transactions:
        if item in counts:
            counts[item] += 1
        else:
            counts[item] = 1
   
    sorted_items = sorted(counts.items(), key=lambda x: (-x[1], x[0]))
   
    result = []
    for item, count in sorted_items:
        result.append(f"{item} {count}")
   
    return result

Group Transactionsโœ…
def getPasswordStrength(passwords, common_words):
    result = []
    for password in passwords:
        is_weak = False
       
        if password.lower() in common_words:
            is_weak = True
        else:
            for word in common_words:
                if word.lower() in password.lower():
                    is_weak = True
                    break
       
        if password.isdigit():
            is_weak = True
       
        if password.islower() or password.isupper():
            is_weak = True
       
        if len(password) < 6:
            is_weak = True
       
        result.append("weak" if is_weak else "strong")
   
    return result


GetPasswordStrengthโœ…
def binary_converter(binary, base='d'):
    binary_str = ''.join(map(str, binary))
    decimal_num = int(binary_str, 2)
    if base == 'd':
        return str(decimal_num)
    elif base == 'b':
        return bin(decimal_num)[2:]
    elif base == 'o':
        return oct(decimal_num)[2:]
    elif base == 'x':
        return hex(decimal_num)[2:]
    else:
        return "Invalid base"


Python Binary converter โœ…
def find_suspicious_users(logs, threshold):
    transaction_count = {}
   
    for log in logs:
        sender, recipient, _ = log.split()
        transaction_count[sender] = transaction_count.get(sender, 0) + 1
        transaction_count[recipient] = transaction_count.get(recipient, 0) + 1
   
    suspicious_users = [user_id for user_id, count in transaction_count.items() if count >= threshold]
   
    return sorted(suspicious_users, key=int)


Find Suspicious Usersโœ…
def stemmer(text):
    stemmed_text = []
    suffixes = ['ed', 'ly', 'ing']
   
    for word in text.split():
        if word.endswith(tuple(suffixes)):
            word = word[:-2] if word.endswith('ed') else word[:-3]
            if len(word) > 8:
                word = word[:8] 
        stemmed_text.append(word)
   
    return ' '.join(stemmed_text)

Suffix stripping stemmer โœ…
import pandas as pd


def saleorder(df):
    grouped = df.groupby(['date added', 'type'])
    for (_, group), (_, sold_group) in zip(grouped, grouped):
        if group['type'].iloc[0] == 'Received':
            received_sizes = group['sizes'].str.split('/').explode().unique()
            sold_sizes = sold_group['sizes'].str.split('/').explode().unique()
            if all(size in sold_sizes for size in received_sizes):
                print("Possible")
            else:
                print("Not Possible")



Verify Sale Orderโœ…
๐Ÿ‘1
class Message(object):
    def init(self, message: str, sender: int, receiver: int) -> None:
        self.message = message
        self.sender = sender
        self.receiver = receiver

    def str(self) -> str:
        return self.message

    def eq(self, other: object) -> bool:
        if not isinstance(other, Message):
            return False
        return self.message == other.message

Message Objects โœ…
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
def stemmer(text):     stemmed_text = []     suffixes = ['ed', 'ly', 'ing']         for word in text.split():         if word.endswith(tuple(suffixes)):             word = word[:-2] if word.endswith('ed') else word[:-3]             if len(word) > 8:                โ€ฆ
#include <iostream>
#include <sstream>
#include <string>
#include <vector>

std::string stemmer(const std::string& text) {
    std::stringstream ss(text);
    std::string word;
    std::vector<std::string> stemmed_words;

    while (ss >> word) {
        if (word.size() > 2 && (word.substr(word.size() - 2) == "ed" word.substr(word.size() - 2) == "ly" word.substr(word.size() - 3) == "ing")) {
            word = word.substr(0, word.size() - 2);
        }
        if (word.size() > 8) {
            word = word.substr(0, 8);
        }
        stemmed_words.push_back(word);
    }

    std::string result;
    for (const std::string& stemmed_word : stemmed_words) {
        result += stemmed_word + " ";
    }


    result.pop_back();
    return result;
}

int main() {
    std::string text = "an extremely dangerous dog is barking";
    std::cout << stemmer(text) << std::endl;  // Output: "an extreme dangerou dog is bark"

    return 0;
}

Suffix stripping stemmer โœ