๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
9.62K 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 letterCaseDifference(typedText: str) -> int:
    upper_count = 0
    lower_count = 0
    for char in typedText:
        if char.isupper():
            upper_count += 1
        elif char.islower():
            lower_count += 1
    return upper_count - lower_count

Visa โœ…
from collections import Counter
def countValidWords(s):
    def is_valid(word):
        if len(word) < 3:
            return False
        if not all(char.isalnum() for char in word):
            return False
        has_vowel = any(char.lower() in 'aeiou' for char in word)
        has_consonant = any(char.isalpha() and char.lower() not in 'aeiou' for char in word)
        return has_vowel and has_consonant
    words = s.split()
    count = sum(1 for word in words if is_valid(word))
    return count


Word Count Tool โœ…
def roman_to_decimal(a):
    b = {'I': 1, 'V': 5, 'X': 10, 'L': 50} 
    c = 0 

    for i in range(len(a)):
        if i > 0 and b[a[i]] > b[a[i - 1]]:
            c += b[a[i]] - 2 * b[a[i - 1]]
        else:
            c += b[a[i]]

    return c

def sortRoman(names):
    def custom_sort(e):
        d = e.split() 
        return (d[0], roman_to_decimal(d[1]))

    sorted_names = sorted(names, key=custom_sort)
    return sorted_names
Romanizer โœ…
๐Ÿ‘1
def a(b, c, d, e, f, g):
    if c == e:
        g.append(tuple(sorted(f)))
        return
    if c > e or b >= len(d):
        return
    a(b + 1, c + d[b], d, e, f + [d[b]], g)
    a(b + 1, c, d, e, f, g)
def h(i, j, k):
    l = []
    a(0, 0, k, j, [], l)
    m = set(l)
    return len(m)
n, k = map(int, input().split()) 
pieces = list(map(int, input().split()))
print(h(n, k, pieces))


The Puzzle Masters of puzzleville โœ…
DeltaX
๐Ÿ‘1๐Ÿคฎ1
#include <vector>
#include <algorithm>

bool isPal(int x) {
    int orig = x, rev = 0;
    while (x > 0) {
        rev = rev * 10 + x % 10;
        x /= 10;
    }
    return orig == rev;
}
vector<int> solution(vector<int>& trans) {
    vector<int> pal;
    for (int t : trans) {
        if (isPal(t)) {
            pal.push_back(t);
        }
    }
    sort(pal.rbegin(), pal.rend());
    return pal;
}

Visa โœ…
from collections import deque
def solution(latencies, threshold):
    m = deque() 
    n = deque() 
    start = 0 
    max_len = 0
    for end in range(len(latencies)):
        while m and latencies[m[-1]] <= latencies[end]:
            m.pop()
        while n and latencies[n[-1]] >= latencies[end]:
            n.pop()
        m.append(end)
        n.append(end)
        while latencies[m[0]] - latencies[n[0]] > threshold:
            start += 1
            if m[0] < start:
                m.popleft()
            if n[0] < start:
                n.popleft()
        max_len = max(max_len, end - start + 1)
    return max_len


Visa โœ…
def findLocalMaximums(a):
    def is_local_maximum(b, c):
        d = a[b][c]
        if d == 0:
            return False
        r = d * 2 + 1
        h = d
        rs = max(0, b - h)
        rn = min(len(a) - 1, b + h)
        cs = max(0, c - h)
        cn = min(len(a[0]) - 1, c + h)
        for x in range(rs, rn + 1):
            for y in range(cs, cn + 1):
                if (x == b - h and (y == c - h or y == c + h)) or \
                   (x == b + h and (y == c - h or y == c + h)):
                    continue 
                if (x, y) != (b, c) and a[x][y] >= d:
                    return False
        return True

    result = []
    for b in range(len(a)):
        for c in range(len(a[0])):
            if is_local_maximum(b, c):
                result.append([b, c])
   
    return sorted(result)


Visa โœ…
๐Ÿ‘1