๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
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
Exciting Opportunity for freshers to Kickstart their Career โค๏ธโค๏ธโค๏ธ๐Ÿ’ฅ๐Ÿ’ฅ๐Ÿ’ฅ๐Ÿ’ช๐Ÿ’ช๐Ÿ’ช

Freshers WalkIn Alert ๐Ÿ”ฅ๐Ÿ”ฅ

Process- Back Office

Eligibility - Only Fresher/ Intern

Graduate- 2021 or above

Note- BE/B.Tech are not eligible.

Location: Gurgaon

Date of Interview: 23rd August, 2024.
Time: 10 AM

Address: 8th Floor, Big Audi, Tower C, Building 14, Sector 24 & 25 A, Gurugram- 122001.

Things to Carry:
Aadhaar Card
2 Copy of Resume

To confirm attendance, email
harmeet.2.singh@bt.com with "Yes, I will be coming" for prior security approval.
๐Ÿ‘2
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include<climits>
using namespace std;

const int MOD = 1e9 + 7;

class Solution {
public:
    int removeIntegers(int N, int P, int Q, vector<int>& special_integers) {
        sort(special_integers.begin(), special_integers.end());
        unordered_map<int, bool> is_special;
        for (int num : special_integers)
            is_special[num] = true;

        return minCost(1, 1 << N, P, Q, is_special);
    }

private:
    int minCost(int start, int end, int P, int Q, unordered_map<int, bool>& is_special) {
        int length = end - start + 1;

        if (length == 1) {
            return is_special[start] ? P : Q;
        }

        if (is_power_of_two(length)) {
            return is_special[start] ? (P * length) : Q;
        }

        int min_cost = INT_MAX;

        for (int mid = start; mid < end; ++mid) {
            int left_length = mid - start + 1;
            int right_length = end - mid;

            int left_cost = minCost(start, mid, P, Q, is_special);
            int right_cost = minCost(mid + 1, end, P, Q, is_special);

            min_cost = min(min_cost, left_cost + right_cost);
        }

        min_cost = min(min_cost, is_special[start] ? (P * length) : Q);

        return min_cost;
    }

    bool is_power_of_two(int n) {
        return (n & (n - 1)) == 0;
    }
};

BNYโœ…
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
import java.util.*;

public class Main {
    static int countUniqueSubsets(int[] arr, int N, int K) {
        Arrays.sort(arr);
        return countUniqueSubsetsUtil(arr, N, K, 0, 0);
    }
   
    static int countUniqueSubsetsUtil(int[] arr, int N, int K, int currentIndex, int currentSum) {
        if (currentSum == K) {
            return 1;
        }
        if (currentSum > K || currentIndex >= N) {
            return 0;
        }
       
        int count = 0;
       
     
        count += countUniqueSubsetsUtil(arr, N, K, currentIndex + 1, currentSum + arr[currentIndex]);
       
     
        while (currentIndex + 1 < N && arr[currentIndex] == arr[currentIndex + 1]) {
            currentIndex++;
        }

   
        count += countUniqueSubsetsUtil(arr, N, K, currentIndex + 1, currentSum);
       
        return count;
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int K = scanner.nextInt();
        int[] arr = new int[N];
       
        for (int i = 0; i < N; i++) {
            arr[i] = scanner.nextInt();
        }
       
        System.out.println(countUniqueSubsets(arr, N, K));
    }
}

The puzzle masters of puzzleville โœ…
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
import java.util.*;
import java.io.*;

class Main {
    public static void main(String args[]) throws Exception {
        Scanner sc = new Scanner(System.in);
        String input = sc.nextLine();
        int indent = 0;
        boolean inQuotes = false;
        StringBuilder output = new StringBuilder();

        for (char ch : input.toCharArray()) {
            switch (ch) {
                case '{':
                case '[':
                    output.append(ch);
                    if (!inQuotes) {
                        output.append("\n");
                        indent++;
                        appendIndentation(output, indent);
                    }
                    break;
                case '}':
                case ']':
                    if (!inQuotes) {
                        output.append("\n");
                        indent--;
                        appendIndentation(output, indent);
                    }
                    output.append(ch);
                    break;
                case ',':
                    output.append(ch);
                    if (!inQuotes) {
                        output.append("\n");
                        appendIndentation(output, indent);
                    }
                    break;
                case '"':
                    output.append(ch);
                    inQuotes = !inQuotes;
                    break;
                default:
                    output.append(ch);
                    break;
            }
        }
        System.out.println(output.toString());
    }

    private static void appendIndentation(StringBuilder sb, int indent) {
        for (int i = 0; i < indent; i++) {
            sb.append("**");
        }
    }
}

Json formatter โœ…
#include <bits/stdc++.h>
using namespace std;
string solve(long long N) {
    if (N == 0) return "0";
   
    string ans;
    while (N) {
        int t = N % 62;
        if (t <= 9)
            ans.push_back('0' + t);
        else if (t <= 35)
            ans.push_back('A' + t - 10);
        else
            ans.push_back('a' + t - 36);
       
        N /= 62;
    }
    reverse(ans.begin(), ans.end());
    return ans;
}

Encodeโœ…
long wt = 0, ct = 0;
        for (int i = 0; i < N; i++) {
            if (patients[i][0] > ct) {
                ct = patients[i][0];
            }
            wt += ct + patients[i][1] - patients[i][0];
            ct += patients[i][1];
        }
        return wt / N;

Doctor โœ…
#include <bits/stdc++.h>
using namespace std;

void solve(int N, int M, vector<pair<int, int>>& a, int q, vector<int>& queries) {
    vector<vector<int>> adj(N + 1);

    for (int i = 0; i < M; ++i) {
        int u = a[i].first;
        int v = a[i].second;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    for (int i = 1; i <= N; ++i) {
        sort(adj[i].begin(), adj[i].end());
    }

    for (int i = 0; i < q; ++i) {
        int prof = queries[i];

        if (adj[prof].empty()) {
            cout << -1 << endl;
        } else {
            for (int nbr : adj[prof]) {
                cout << nbr << " ";
            }
            cout << endl;
        }
    }
}

professors city โœ…
๐Ÿ‘1
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
from collections import defaultdict
def countOfAtoms(formula: str) -> str:
    def parse_formula(i):
        n = len(formula)
        count = defaultdict(int)
        while i < n:
            if formula[i] == '(':
                i, inner_count = parse_formula(i + 1)
                multiplier = 0
                i += 1
                while i < n and formula[i].isdigit():
                    multiplier = multiplier * 10 + int(formula[i])
                    i += 1
                multiplier = multiplier or 1
                for elem in inner_count:
                    count[elem] += inner_count[elem] * multiplier
            elif formula[i] == ')':
                return i, count
            else:
                j = i + 1
                while j < n and formula[j].islower():
                    j += 1
                element = formula[i:j]
                i = j
                multiplier = 0
                while j < n and formula[j].isdigit():
                    multiplier = multiplier * 10 + int(formula[j])
                    j += 1
                count[element] += max(multiplier, 1)
                i = j
        return i, count

    _, counts = parse_formula(0)
    sorted_elements = sorted(counts.items())
    result = []
    for element, count in sorted_elements:
        result.append(element)
        if count > 1:
            result.append(str(count))
    return ''.join(result)
#include <bits/stdc++.h>
using namespace std;
int splitIntoTwo(vector<int> arr) {
    int n = arr.size();
    int total_sum = accumulate(arr.begin(), arr.end(), 0);
    int left_sum = 0;
    int count = 0;
        for(int i = 0; i < n - 1; i++) {
        left_sum += arr[i];
        int right_sum = total_sum - left_sum;
       
        if(left_sum > right_sum) {
            count++;
        }
    }
   
    return count;
}


Array splitting โœ