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

vector<int> twoDimensions(vector<string> coordinates, int n) {
    vector<int> maxAndCount(2);
    vector<vector<int>> grid(n, vector<int>(n, 0));
    int arrLength = coordinates.size();
    int max_val = INT_MIN;
    int count = 1;

    for (int i = 0; i < arrLength; i++) {
        stringstream ss(coordinates[i]);
        int row, column;
        ss >> row >> column;

        for (int j = 0; j < row; j++) {
            for (int k = 0; k < column; k++) {
                grid[j][k] += 1;

                if (grid[j][k] > max_val) {
                    max_val = grid[j][k];
                    count = 1;
                } else if (grid[j][k] == max_val) {
                    count++;
                }
            }
        }
    }

    maxAndCount[0] = max_val;
    maxAndCount[1] = count;

    return maxAndCount;
}

int main() {
    vector<string> coors = { "2 3", "3 7", "4 1"};
    vector<int> result = twoDimensions(coors, 7);  // Change 3 to 7 for the grid size
    cout <<result[1] << endl;
    return 0;
}

Oracle โœ…
Growth in 2 Dimension
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 โœ