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

#define INF INT_MAX

int minimumStressLevel(int N, vector<vector<int>>& abw, int X, int Y) {
  
    vector<vector<pair<int, int>>> graph(N + 1);
    for (auto& road : abw) {
        int a = road[0], b = road[1], w = road[2];
        graph[a].push_back({b, w});
        graph[b].push_back({a, w});
    }
   
 
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
    vector<int> dist(N + 1, INF);
    pq.push({0, X});
    dist[X] = 0;

    while (!pq.empty()) {
        int u = pq.top().second;
        int stress = pq.top().first;
        pq.pop();

        if (u == Y) return stress;

        for (auto& neighbor : graph[u]) {
            int v = neighbor.first;
            int w = neighbor.second;
            int new_stress = max(stress, w);
            if (new_stress < dist[v]) {
                dist[v] = new_stress;
                pq.push({new_stress, v});
            }
        }
    }

    return -1;
}
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
void dfs(int node, int parent, const vector<vector<int>>& adj, const vector<bool>& hasFruit, vector<bool>& visited, int& time) {
    visited[node] = true;
    for (int neighbor : adj[node]) {
        if (neighbor == parent || visited[neighbor]) continue;
        dfs(neighbor, node, adj, hasFruit, visited, time);
        if (hasFruit[neighbor]) {
            time += 2;
        }
    }
}
int minTime(int n, vector<vector<int>>& edges, vector<bool>& hasFruit) {
    vector<vector<int>> adj(n);
    for (const auto& edge : edges) {
        adj[edge[0]].push_back(edge[1]);
        adj[edge[1]].push_back(edge[0]);
    }

    int time = 0;
    vector<bool> visited(n, false);
    dfs(0, -1, adj, hasFruit, visited, time);
    return time;
}

Magical Forest โœ…
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
def min_window(s: str, t: str) -> str:
    from collections import Counter

   
    target_count = Counter(t)
    required_count = len(target_count)
    formed = 0
    window_counts = {}
   
   
    min_window_length = float('inf')
    min_window_start = 0
    left, right = 0, 0

  
    while right < len(s):
       
        char = s[right]
        window_counts[char] = window_counts.get(char, 0) + 1
       
     
        if char in target_count and window_counts[char] == target_count[char]:
            formed += 1
       
       
        while left <= right and formed == required_count:
          
            if right - left + 1 < min_window_length:
                min_window_length = right - left + 1
                min_window_start = left
           
         
            char = s[left]
            window_counts[char] -= 1
            if char in target_count and window_counts[char] < target_count[char]:
                formed -= 1
           
           
            left += 1
       
       
        right += 1
   
   
    return s[min_window_start:min_window_start + min_window_length] if min_window_length != float('inf') else "N/A"
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
#include <iostream> #include <vector> #include <algorithm> using namespace std; void dfs(int node, int parent, const vector<vector<int>>& adj, const vector<bool>& hasFruit, vector<bool>& visited, int& time) {     visited[node] = true;     for (int neighborโ€ฆ
import java.util.*;

public class Solution{
   
    static class TreeNode {
        int id;
        boolean hasFruit;
        List<TreeNode> children;

        TreeNode(int id, boolean hasFruit) {
            this.id = id;
            this.hasFruit = hasFruit;
            this.children = new ArrayList<>();
        }
    }
   
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
       
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int columns = scanner.nextInt();  used.
       
        TreeNode[] nodes = new TreeNode[n];
        for (int i = 0; i < n; i++) {
            nodes[i] = new TreeNode(i, false);
        }
       
        for (int i = 0; i < m; i++) {
            int u = scanner.nextInt();
            int v = scanner.nextInt();
            nodes[u].children.add(nodes[v]);
            nodes[v].children.add(nodes[u]);
        }
       
        int treeCount = scanner.nextInt();
        boolean[] hasFruit = new boolean[treeCount];
        for (int i = 0; i < treeCount; i++) {
            hasFruit[i] = scanner.nextInt() == 1;
        }
       
        for (int i = 0; i < treeCount; i++) {
            nodes[i].hasFruit = hasFruit[i];
        }
       
        boolean[] visited = new boolean[n];
        Result result = new Result();
        dfs(nodes[0], visited, result);
       
        System.out.println(result.time);
    }
   
    static class Result {
        int time = 0;
    }
   
    private static boolean dfs(TreeNode node, boolean[] visited, Result result) {
        visited[node.id] = true;
        boolean foundFruit = node.hasFruit;
       
        for (TreeNode child : node.children) {
            if (!visited[child.id]) {
                if (dfs(child, visited, result)) {
                    result.time += 2;  back
                    foundFruit = true;
                }
            }
        }
       
        return foundFruit;
    }
}

Magical Forest โœ…
Exciting Internship Opportunity: Frontend SDE Intern

Role: Frontend SDE Intern
Company: Blendnet.ai
Stipend: โ‚น25,000 per month
Perks: Pre-Placement Offer (PPO)
Responsibilities: Develop user-facing features, engage in responsive design, collaborate with UX/UI designers, optimize application performance, and maintain documentation.

Apply Now ๐Ÿ”—: https://www.foundit.in/zuno/app/job/frontend-sde-intern/description?utm_source=campus-ambassador&utm_medium=di_summer_blendnet_1&utm_campaign=ZW4204

Exciting Internship Opportunity: Frontend SDE Intern

Role: Frontend SDE Intern
Company: Blendnet.ai
Stipend: โ‚น25,000 per month
Perks: Pre-Placement Offer (PPO)
Responsibilities: Develop user-facing features, engage in responsive design, collaborate with UX/UI designers, optimize application performance, and maintain documentation.

Apply Now ๐Ÿ”—: https://www.foundit.in/zuno/app/job/frontend-sde-intern/description?utm_source=campus-ambassador&utm_medium=di_summer_blendnet_1&utm_campaign=ZW4204
def minutes_until_overlap(current_time):
    hours, minutes = map(int, current_time.split(':'))
    total_minutes = hours * 60 + minutes
    minutes_until_overlap = (60 - total_minutes) % 60
    return minutes_until_overlap

IBMโœ