FRESHERS ADDA
14.9K subscribers
11 photos
4 files
234 links
Placement info for 2022 Batch

πŸŽŠπŸŽ‰Note: Daily Updates On Placements (ON+OFF CAMPUS) with MaterialsπŸ†πŸŽ–οΈ
Download Telegram
FRESHERS ADDA pinned Β«πŸ“Zyoin is Hiring C++ Developer Location : Bangalore, Chennai Salary: Best in industry Required Skills : c++, OOP,multithreading Microservices πŸ“ŒApply : https://bit.ly/3Me11An https://bit.ly/3Me11An https://bit.ly/3Me11An https://bit.ly/3Me11An h…»
β­•οΈπŸš€ Join NINJA SLAYGROUND - 21 days of coding thrill! Win INR 8,00,000 in prizes. πŸ†

INR 8,00,000 Prize Pool!
Daily Milestone Rewards.
Win Coding Ninjas x SLAY Coffee Merch.
πŸ”₯ How:
1️⃣ Register at : https://bit.ly/3qphD2w
2️⃣ Solve a daily coding challenge.
3️⃣ Tweet with #NinjaSlayground, #CodingNinjasStudio, and tag and
4️⃣ Code for 21 days! πŸ’ͺ

Let’s code, conquer, brew success! β˜•οΈ

Register Now to Ninja Slayground: Rise Above, Conquer All. πŸš€

πŸ“Œ
FRESHERS ADDA pinned Β«β­•οΈπŸš€ Join NINJA SLAYGROUND - 21 days of coding thrill! Win INR 8,00,000 in prizes. πŸ† INR 8,00,000 Prize Pool! Daily Milestone Rewards. Win Coding Ninjas x SLAY Coffee Merch. πŸ”₯ How: 1️⃣ Register at : https://bit.ly/3qphD2w 2️⃣ Solve a daily coding challenge.…»
#include<stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    int arr[n];
    for(int i=0;i<n;i++)
    {
        scanf("%d",&arr[i]);
    }
    int count=0;
    int num=arr[0];
    for(int i=1;i<n;i++)
    {
       if(num!=arr[i])
            count++;
    }
    printf("%d",count);
}

C Language
TCS 1st Qsn

---------------------------------------------------------

N=int(input())
K=int(input())
price=list(map(int,input().split()))
vol=list(map(int,input().split()))
maxvol=0
volu=0
maxvol=max(vol)
for i in range(0,N):
    if (maxvol==vol[i] and price[i]<=K):
        K=K-price[i]
        volu=maxvol
for i in range(0,N):
    for j in range(i+1,N+1):
        if (price[i]<=K and price[i]==price[j]):
            if (vol[i]>vol[j]):
                volu=volu+vol[i]
                K=K-price[i]
            else:
                volu=volu+vol[j]
                K=K-price[j]
        elif (price[i]<=K and price[i]!=price[j]):
            K=K-price[i]
            -------

include<stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    int arr[n];
    for(int i=0;i<n;i++)
    {
        scanf("%d",&arr[i]);
    }
    int count=0;
    int num=arr[0];
    for(int i=1;i<n;i++)
    {
       if(num!=arr[i])
            count++;
    }
    printf("%d",count);
}

Array Code in C language
int main() {
int n, m, k, d = 1, rv = 0;
cin >> n >> m;
vector<set<int>> f(n);
for (int i = 0, u, v; i < m; ++i) {
cin >> u >> v;
f[u].insert(v);
f[v].insert(u);
}
cin >> k;
vector<bool> w(n, true);
rv = n;
while (rv < k) {
vector<bool> nw(n, false);
for (int i = 0; i < n; ++i) {
int cnt = 0;
for (int fr : f[i]) cnt += w[fr];
if (w[i] && cnt == 3) nw[i] = true;
else if (!w[i] && cnt < 3) nw[i] = true;
}
w = nw;
rv += count(w.begin(), w.end(), true);
++d;
}
cout << d;
return 0;
}
Office Rostering
C+
TCS exam
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>

using namespace std;

struct Line {
int x1, y1, x2, y2;
};
int countCells(Line line, pair<int, int> star, bool split) {
if (line.x1 == line.x2) {
if (split) {
return min(abs(star.second - line.y1), abs(star.second - line.y2)) + 1;
}
else {
return abs(line.y1 - line.y2) + 1;
}
}
else {
if (split) {
return min(abs(star.first - line.x1), abs(star.first - line.x2)) + 1;
}
else {
return abs(line.x1 - line.x2) + 1;
}
}
}
bool intersects(Line a, Line b, pair<int, int>& intersection) {
if (a.x1 == a.x2 && b.y1 == b.y2) {
if (b.x1 <= a.x1 && a.x1 <= b.x2 && a.y1 <= b.y1 && b.y1 <= a.y2) {
intersection = {a.x1, b.y1};
return true;
}
}
if (a.y1 == a.y2 && b.x1 == b.x2) {
if (a.x1 <= b.x1 && b.x1 <= a.x2 && b.y1 <= a.y1 && a.y1 <= b.y2) {
intersection = {b.x1, a.y1};
return true;
}
}
return false;
}
int main() {
int N, K;
cin >> N;
vector<Line> lines(N);
for (int i = 0; i < N; ++i) {
cin >> lines[i].x1 >> lines[i].y1 >> lines[i].x2 >> lines[i].y2;
if (lines[i].x1 > lines[i].x2 || (lines[i].x1 == lines[i].x2 && lines[i].y1 > lines[i].y2)) {
swap(lines[i].x1, lines[i].x2);
swap(lines[i].y1, lines[i].y2);
}
}
cin >> K;
map<pair<int, int>, vector<Line>> stars;
for (int i = 0; i < N; ++i) {
for (int j = i + 1; j < N; ++j) {
pair<int, int> intersection;
if (intersects(lines[i], lines[j], intersection)) {
stars[intersection].push_back(lines[i]);
stars[intersection].push_back(lines[j]);
}
}
}

int asiylam = 0;
for (auto& star : stars) {
if (star.second.size() / 2 == K) {
vector<int> intensities;
for (auto& line : star.second) {
intensities.push_back(countCells(line, star.first, true));
}
asiylam += *min_element(intensities.begin(), intensities.end());
}
}
cout << asiylam << endl;
return 0;
}

Magic Star Intensity Code
C++
TCS Exam
Tcs exam
int main() {
    string s;
    cin >> s;
    int n = s.length(), res = 0;
    vector<int> v(n);
    for (int i = 0; i < n; ++i) cin >> v[i];
    int lw = s[0] - '0', lwv = v[0];
    for (int i = 1; i < n; ++i) {
        if (s[i] - '0' == lw) {
            res += min(lwv, v[i]);
            lwv = max(lwv, v[i]);
        } else {
            lw = s[i] - '0';
            lwv = v[i];
        }
    }
    cout << res;
    return 0;
}
Form alternating string

Change accordingly before submitting to avoid plagiarism