๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
9.52K subscribers
5.56K photos
3 videos
95 files
9.7K 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
from queue import Queue

def solution(N, A, B, M):
    degree = [0] * N
    for i in range(M):
        degree[A[i]] += 1
        degree[B[i]] += 1

    q = Queue()
    for i in range(N):
        if degree[i] <= 1:
            q.put(i)

    seconds = 0
    while not q.empty():
        q_size = q.qsize()
        for i in range(q_size):
            vertex = q.get()

            for j in range(M):
                if A[j] == vertex or B[j] == vertex:
                    other_vertex = B[j] if A[j] == vertex else A[j]
                    degree[other_vertex] -= 1
                    if degree[other_vertex] == 1:
                        q.put(other_vertex)
        seconds += 1

    return seconds

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

int main() {
    int n;
    cin>>n;
    vector<int>arr(n);
    for(int i=0;i<n;i++)
    cin>>arr[i];
    int x;
    int y;
    cin>>x>>y;
    int ans=INT_MAX;
    for(int i=0;i<y;i++)
    {
        if(i+(x-1)*y<n)
        {
            int low=i;
            int high=i;
            int curr=0;
            int count=x;
            while(high<n and count>0)
            {
                curr+=arr[high];
                high+=y;
                count--;
            }
            // cout<<curr<<endl;
            ans=min(ans,curr);
            while(high<n)
            {
                curr+=arr[high];
                curr-=arr[low];
                low+=y;
                high+=y;
                ans=min(ans,curr);
            }
        }
    }
    cout<<ans;
    return 0;
}
public static int numPaths(List<List<Integer>> warehouse) {
    int r = warehouse.size(), c = warehouse.get(0).size();
    int[][] paths = new int[r][c];
   
    if (warehouse.get(0).get(0) == 1)
        paths[0][0] = 1;
   
    for (int i = 1; i < r; i++) {
        if (warehouse.get(i).get(0) == 1)
            paths[i][0] = paths[i - 1][0];
    }
   
    for (int j = 1; j < c; j++) {
        if (warehouse.get(0).get(j) == 1)
            paths[0][j] = paths[0][j - 1];
    }
   
    for (int i = 1; i < r; i++) {
        for (int j = 1; j < c; j++) {
            if (warehouse.get(i).get(j) == 1)
                paths[i][j] = paths[i - 1][j] + paths[i][j - 1];
        }
    }
   
    return paths[r - 1][c - 1];
}

Paths in warehouse โœ…
Magicpin hiring Interns across product, analytics and strategy and ops. This opportunity is for all college students to work remotely along with their colleges.

What we are looking for:
๏ปฟ๏ปฟGood analytical and problem solving skills
๏ปฟ๏ปฟHigh ownership
๏ปฟ๏ปฟAbility to learn quickly

If you are interested, please drop me an email on arshdeep.gulati@magicpin.in