๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
9.62K subscribers
5.59K photos
3 videos
95 files
10.2K 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
public static List<Integer> solution(int[] forest, int bird) {
        List<Integer> result = new ArrayList<>();
        int length = 0;
        boolean flyRight = true;

        while (length < 100) {
            int pos = bird;
            int stickLength = 0;

            if (flyRight) {
                while (pos < forest.length && forest[pos] == 0) {
                    pos++;
                }
            } else {
                while (pos >= 0 && forest[pos] == 0) {
                    pos--;
                }
            }

            if (pos >= 0 && pos < forest.length) {
                stickLength = forest[pos];
                bird = pos;
                result.add(pos);
                forest[pos] = 0;
                length += stickLength;
            }

            flyRight = !flyRight;
        }

        return result;
    }.

Coinbase โœ…
#include <stdio.h>
#include <stdlib.h>

int compare(const void *a, const void *b) {
    return (*(int *)a - *(int *)b);
}

void findSegmentsAfterDestruction(int* houses, int housesSize, int* queries, int queriesSize, int* result) {
    qsort(houses, housesSize, sizeof(int), compare);
    int pos[100001] = {0};
    for (int i = 0; i < housesSize; i++) {
        pos[houses[i]] = 1;
    }
   
    int segments = 1;
    for (int i = 1; i < housesSize; i++) {
        if (houses[i] != houses[i-1] + 1) segments++;
    }
   
    for (int i = 0; i < queriesSize; i++) {
        int house = queries[i];
        pos[house] = 0;
       
        int hasLeftNeighbor = house > 0 ? pos[house - 1] : 0;
        int hasRightNeighbor = pos[house + 1];
       
        if (hasLeftNeighbor && hasRightNeighbor) {
            segments++;
        } else if (!hasLeftNeighbor && !hasRightNeighbor) {
            segments--;
        }
        result[i] = segments;
    }
}

Coinbase โœ…
ReNew

We are looking to hire Graduate Engineer Trainees (GETs) who are fresh engineering graduates of the batch of 2024. These GETs will be a part of our manufacturing plant based in Dholera, Gujarat.

Interested candidates can click on the link to apply: https://forms.microsoft.com/pages/responsepage.aspx?id=gYP1nQXYxUCc6blOxwqHDYIGFOUgRR5Nrc7tUENCB31URFdQTDBWVEoxQkNVSjA4REFOTjVRMk9USy4u

Profile & Eligibility Criteria:
ยท        Fresh graduates (Graduation year - 2024).
ยท        Specialization: B.Tech. Electrical/Electronics
ยท        Good analytical and communication skills.
ยท        Working knowledge of MS-Office suite (Excel, Word, and PowerPoint).
ยท        Energized and highly motivated individuals with a passion to work in the clean energy space.
ยท        Demonstrate ReNew values of Pioneering, Responsibility, Excellence, and Responsibility.
ยท        Go-getter attitude with an ability to work in a fast-paced environment.
ยท        Ability to work under pressure and manage ambiguity.
#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>

using namespace std;

vector<vector<string>> solve(vector<string>& strs) {
    unordered_map<string, vector<string>> mp;
    for (string s : strs) {
        string t = s;
        sort(t.begin(), t.end());
        mp[t].push_back(s);
    }
    vector<vector<string>> anagrams;
    for (auto p : mp) {
        anagrams.push_back(p.second);
    }
    return anagrams;
}

int main() {
    int n;
    cin >> n;
    vector<string> strs(n);
    for (int i = 0; i < n; i++) {
        cin >> strs[i];
    }
    vector<vector<string>> ans = solve(strs);
    int maxi= 0;
    for (auto g : ans) {
        maxi = max(maxi, (int)g.size());
    }
    for (auto g : ans) {
        if (g.size() == maxi) {
            for (string s : g) {
                cout << s << " ";
            }
            cout << endl;
        }
    }
    return 0;
}

Anagram
Salesforce โœ…
๐Ÿ‘Ž3๐Ÿ‘2
int calc(long long n) {
long long t = sqrt(n * 2);
while(t * (t + 1) / 2 > n) t--;
while((t + 1) * (t + 2) / 2 <= n) t++;
return t;
};

void getMaxHeight() {
long long n, m; cin >> n >> m;
int turn = 0;
int ans = 0;
int res = 0;
res = max(calc(n), calc(m));
for(int i = 1; i <= 1000000000; i++) {
  if(!turn) {
   if(n < i) {
    break;
   } else {
    n -= i;
    ans++;
    res = max(res, ans + calc(m));
   }
  } else {
   if(m < i) {
    break;
   } else {
    m -= i;
    ans++;
    res = max(res, ans + calc(n));
   }
  }
  turn ^= 1;
}

cout << max(ans, res);
}

Trailhead โœ…
Salesforce
๐Ÿ‘1
const int N = 2000 + 10;
int cnt[N][N], dp[N][N];
float highest_density(vector<vector<int>> points) {
vector<int> c;
for(auto x : points) {
  c.push_back(x[0]);
  c.push_back(x[1]);
}
sort(c.begin(), c.end());
c.resize(unique(c.begin(), c.end()) - c.begin());
for(auto &p : points) {
  for(auto &x : p) {
   x = lower_bound(c.begin(), c.end(), x) - c.begin() + 1;
  }
  cnt[p[0]][p[1]]++;
}

for(int i = 1; i <= 2000; i++) {
  for(int j = 1; j <= 2000; j++) {
   dp[i][j] = cnt[i][j] + dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1];
  }
}

float ans = -1.0;
for(int i = 0; i < points.size(); i++) {
  for(int j = i + 1; j < points.size(); j++) {
   int x = points[i][0], y = points[i][1];
   int u = points[j][0], v = points[j][1];
   if(x > u) swap(x, u);
   if(y > v) swap(y, v);
   if(x == u || y == v) continue;
   if(!cnt[x][y] !cnt[u][v] !cnt[x][v] || !cnt[u][y]) continue;
   float S = (c[u - 1] - c[x - 1]);
   float T = (c[v - 1] - c[y - 1]);
   x++; u--; y++; v--;
   ans = max(ans, (float)0);
   if(x > u || y > v) continue;
   float pp = dp[u][v] - dp[x - 1][v] - dp[u][y - 1] + dp[x - 1][y - 1];
   pp = pp / S;
   pp = pp / T;
   ans = max(ans, pp);
  }
}

return ans;
}

Rectangle
Salesforce โœ…
๐Ÿ‘2
Do you enjoy reading this channel?

Perhaps you have thought about placing ads on it?

To do this, follow three simple steps:

1) Sign up: https://telega.io/c/cs_algo
2) Top up the balance in a convenient way
3) Create an advertising post

If the topic of your post fits our channel, we will publish it with pleasure.