๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
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 <iostream>
#include <vector>
using namespace std;
int andyTrucker(int N, int K, vector<int>& A) {
    int maxWeight = 0;
    for (int i = 0; i <= N - K; ++i) {
        int currentWeight = 0;
        for (int j = i; j < i + K; ++j) {
            currentWeight += A[j];
        }
        maxWeight = max(maxWeight, currentWeight);
    }

    return maxWeight;
}
#include <bits/stdc++.h>
using namespace std;
vector<int> distinctOrder(int g_nodes, vector<int> g_from, vector<int> g_to) {
    vector<vector<int>> adj(g_nodes + 1);
    for (int i = 0; i < g_from.size(); ++i)
    {
        adj[g_from[i]].push_back(g_to[i]);
        adj[g_to[i]].push_back(g_from[i]);
    }

    for (int i = 1; i <= g_nodes; ++i)
    {
        sort(adj[i].rbegin(), adj[i].rend());
    }

    vector<int> A;
    vector<bool> visited(g_nodes + 1, false);
    priority_queue<int> pq;
    pq.push(g_nodes); 

    while (!pq.empty())
    {
        int node = pq.top();
        pq.pop();

        if (visited[node]) continue;
        visited[node] = true;
        A.push_back(node);

        for (int neighbor : adj[node])
        {
            if (!visited[neighbor])
            {
                pq.push(neighbor);
            }
        }
    }

    return A;
}

Distinct order Traversal โœ