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

int count(vector<int>&coins, int n, int sum)
{

int table[sum + 1];


memset(table, 0, sizeof(table));


table[0] = 1;

for (int i = 0; i < n; i++)
  for (int j = coins[i]; j <= sum; j++)
   table[j] += table[j - coins[i]];
return table[sum];
}

int main()
{
int n,t;
cin>>n>>t;
vector<int>L(t);
for(int i=0;i<t;i++)
{
   cin>>L[i];
}

cout << count(L, t,n);

}

Helpshift โœ…
Goblin
#include <bits/stdc++.h>

using namespace std;

vector<vector<int>> getSkyline(vector<vector<int>>& buildings) {
    vector<vector<int>> ans;
    multiset<int> pq{0};
   
    vector<pair<int, int>> points;
   
    for(auto b: buildings){
        points.push_back({b[0], -b[2]});
        points.push_back({b[1], b[2]});
    }
   
    sort(points.begin(), points.end());
   
    int ongoingHeight = 0;
   
  
    for(int i = 0; i < points.size(); i++){
        int currentPoint = points[i].first;
        int heightAtCurrentPoint = points[i].second;
       
        if(heightAtCurrentPoint < 0){
            pq.insert(-heightAtCurrentPoint);
        } else {
            pq.erase(pq.find(heightAtCurrentPoint));
        }
       
      
        auto pqTop = *pq.rbegin();
        if(ongoingHeight != pqTop){
            ongoingHeight = pqTop;
            ans.push_back({currentPoint, ongoingHeight});
        }
    }
   
    return ans;
}

int main() {
    int n;
   
    cin >> n;

    vector<vector<int>> buildings(n, vector<int>(3));

   
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> buildings[i][j];
        }
    }

    vector<vector<int>> result = getSkyline(buildings);
  
    for (auto &p : result) {
        cout << p[0]<<p[1]<< endl;
    }

   
}

Skyline โœ…
#include <bits/stdc++.h>

using namespace std;

void minimumBribes(vector<int> A)
{
    int n = A.size();
    int cnt = 0;
    for(int i = n - 1; i >= 0; i--)
    {
        if(A[i] != (i + 1))
        {
            if(((i - 1) >= 0) && A[i - 1] == (i + 1))
            {
                cnt++;
                swap(A[i], A[i-1]);
            }
            else if(((i - 2) >= 0) && A[i - 2] == (i + 1))
            {
                cnt += 2;
                A[i - 2] = A[i - 1];
                A[i - 1] = A[i];
                A[i] = i + 1;
            }
            else
            {
                cout << "Too chaotic" << endl;
                return;
            }
        }     
    }
    cout << cnt << endl;
    return;
}

int main() {
    int t;
   
    cin >> t;

    for (int i = 0; i < t; i++) {
        int n;
       
        cin >> n;

        vector<int> A(n);
       
        for (int j = 0; j < n; j++) {
            cin >> A[j];
        }

        minimumBribes(A);
    }

    return 0;
}
Min bribes โœ…
#include<bits/stdc+.h>
using namespace std;

int main()
{
  

int n;
    cin>>n;
   
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
   
   
    int next_greater[n], next_smaller[n];
   
   
    stack<int> s1;
  for ( int i=n-1; i>=0; i--)
    {
       
  while (!s1.empty() && a[s1.top()] <= a[i] )
            s1.pop();

     
        if (!s1.empty())
            next_greater[i] = s1.top();

    
        else
            next_greater[i] = -1;

      
        s1.push(i);
    }
   
  
    stack<int> s2;
  for (int i=n-1; i>=0; i--)
    {
       
        while (!s2.empty() && a[s2.top()] >= a[i])
            s2.pop();

       
  if (!s2.empty())
            next_smaller[i] = s2.top();

     
  else
            next_smaller[i] = -1;

       
        s2.push(i);
    }
   
   
    for (int i=0; i< n; i++)
    {
    
     if (next_greater[i] != -1 && next_smaller[next_greater[i]] != -1)
            cout << a[next_smaller[next_greater[i]]] <<" ";
  else
            cout<<-1<<" ";
    }

}

Number games โœ…
public static int findBestPath(int n, int m, int max_t, List beauty, List u, List v, List t) {
// Write your code here
createGraph(n, m, u, v, t);
// int twoWay = dfs(0, beauty, max_t);
// visited = new HashSet<>();
// cycle(0, beauty, max_t, beauty.get(0), 0);
visited.add(0);
dfs2(0, beauty, max_t, beauty.get(0));
return totalAns;

}

static int totalAns = Integer.MIN_VALUE;

public static void dfs2(int node, List beauty, int maxT, int sum) {

if (node == 0) {
    totalAns = Math.max(totalAns, sum);

}
for (int nbr : map.get(node).keySet()) {

    int time = map.get(node).get(nbr);
    if (time <= maxT) {
        if (!visited.contains(nbr)) {
            visited.add(nbr);
            dfs2(nbr, beauty, maxT - time, sum + beauty.get(nbr));
            visited.remove(nbr);
        } else
            dfs2(nbr, beauty, maxT - time, sum);

    }

}
}

static HashSet<Integer> visited = new HashSet<>();
static HashMap<Integer, HashMap<Integer, Integer>> map = new HashMap<>();

public static void createGraph(int n, int m, List u, List v, List t) {
for (int i = 0; i < n; ++i) {
map.put(i, new HashMap<>());
}

for (int i = 0; i < m; ++i) {
    int x = u.get(i);
    int y = v.get(i);
    int z = t.get(i);

    map.get(x).put(y, z);
    map.get(y).put(x, z);
}
}

Find best path
Linkedln โœ…
int getMinimumCost(vector<int> arr)
{
    long long maxDiff = 0 ;
    int index = -1 ;
    for(int i=  0 ; i < arr.size()-1 ; i++)
    {
        if(abs(arr[i]-arr[i+1]) > maxDiff)
        {
           maxDiff = abs(arr[i]-arr[i+1]) ;
           index = i ;
        }
    }
   
    int median = (arr[index] + arr[index+1]) / 2 ;
   
   
    long long initialCost = 0 ;
   
    for(int i=  0 ; i < arr.size()-1 ; i++)
        initialCost += pow(arr[i]-arr[i+1],2) ;
   
    initialCost = initialCost + pow(arr[index] - median,2) + pow(median - arr[index+1],2) - pow(arr[index] - arr[index+1] ,2) ;
   
    return initialCost ;
}

Linkedln โœ…
DE SHAW hiring Ascend Educare is a six-month mentorship program for women in technology

Eligibility Criteria:

Second/third-year student in a BTech/BE program

Third/fourth-year student in a five-year dual degree program (BTech + MTech, BE + ME)

First-year student in a two-year MTech/MS/MCA program

Second-year student in a three-year MCA program;


https://www.deshawindia.com/forms/REQ5Qjg1RTktM0Q5NC00QjhFLTkyNDYtNTE1OENENjE5QjhB
Software Engineer Swaraj Kumar is offering a group session to help you ace the FAANG interviews and to answer your questions and doubts directly ๐ŸŽฏ

Heโ€™ll be sharing the following:

- Experience and insights on the interview process
- How to enhance your skill set
- Tips to grab high-paying job opportunities
- Ways to build your resume.

Register now - https://visit.preplaced.in/n8u

The session will also include a live Q&A, where the mentor will answer all your doubts and concerns:)

Don't miss out!