๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_set>
using namespace std;
int spreadInfection(vector<vector<int>>& adj, vector<int>& malware, int removeNode = -1) {
int n = malware.size();
vector<int> infected(n, 0);
queue<int> q;
for (int i = 0; i < n; i++) {
if (malware[i] == 1 && i != removeNode) {
q.push(i);
infected[i] = 1;
}
}
while (!q.empty()) {
int node = q.front();
q.pop();
for (int neighbor : adj[node]) {
if (infected[neighbor] == 0 && neighbor != removeNode) {
infected[neighbor] = 1;
q.push(neighbor);
}
}
}
int totalInfected = 0;
for (int i = 0; i < n; i++) {
if (infected[i] == 1) totalInfected++;
}
return totalInfected;
}
int minimizeMalwareSpread(int g_nodes, vector<int>& g_from, vector<int>& g_to, vector<int>& malware) {
vector<vector<int>> adj(g_nodes);
for (int i = 0; i < g_from.size(); i++) {
adj[g_from[i] - 1].push_back(g_to[i] - 1);
adj[g_to[i] - 1].push_back(g_from[i] - 1);
}
int baselineInfection = spreadInfection(adj, malware);
int bestNode = -1;
int minInfected = baselineInfection;
for (int i = 0; i < g_nodes; i++) {
if (malware[i] == 1) {
int infectedCount = spreadInfection(adj, malware, i);
if (infectedCount < minInfected || (infectedCount == minInfected && (bestNode == -1 || i < bestNode))) {
minInfected = infectedCount;
bestNode = i;
}
}
}
return bestNode + 1;
}
Salesforce โ
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Pocket FM is hiring for Multiple Roles
For 2021, 2022, 2023 grads
https://www.linkedin.com/posts/ahujahs_google-forms-sign-in-activity-7244662560166141952-YXb-?utm_source=share&utm_medium=member_desktop
For 2021, 2022, 2023 grads
https://www.linkedin.com/posts/ahujahs_google-forms-sign-in-activity-7244662560166141952-YXb-?utm_source=share&utm_medium=member_desktop
Linkedin
Google Forms: Sign-in | Harsimran Ahuja | 13 comments
#hiring
Join us at Pocket FM and be part of the binge-listening revolution with our captivating audio series! ๐ง We are currently seeking passionate professionals to fill key roles in our team:
๐ธ #GrowthManager (2+ years experience)
๐ธ #ProgramManager (1+โฆ
Join us at Pocket FM and be part of the binge-listening revolution with our captivating audio series! ๐ง We are currently seeking passionate professionals to fill key roles in our team:
๐ธ #GrowthManager (2+ years experience)
๐ธ #ProgramManager (1+โฆ
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
#include <bits/stdc++.h>
using namespace std;
string ltrim(const string &);
string rtrim(const string &);
/*
* Complete the 'isConsistent' function below.
*
* The function is expected to return a BOOLEAN.
* The function accepts STRING_ARRAY expressions as parameter.
*/
bool isConsistent(vector<string> expressions) {
unordered_map<char, vector<char>> graph;
unordered_map<char, int> indegree;
for (char c = 'a'; c <= 'z'; c++) {
indegree[c] = 0;
}
for (string expr : expressions) {
char u = expr[0];
char v = expr[2];
graph[v].push_back(u);
indegree[u]++;
}
queue<char> q;
for (char c = 'a'; c <= 'z'; c++) {
if (indegree[c] == 0) {
q.push(c);
}
}
int visitedCount = 0;
while (!q.empty()) {
char u = q.front();
q.pop();
visitedCount++;
for (char v : graph[u]) {
indegree[v]--;
if (indegree[v] == 0) {
q.push(v);
}
}
}
return visitedCount == 26;
}
Codevilla Numeric Quest
Salesforceโ
int solve(vector<int>& arr, int x) {
int n = arr.size();
int total = accumulate(arr.begin(), arr.end(), 0);
int target = total - x;
if (target < 0) return -1;
if (target == 0) return n;
int maxi = -1, curr = 0;
unordered_map<int, int> pm;
pm[0] = -1;
for (int i = 0; i < n; ++i) {
curr += arr[i];
if (pm.find(curr - target) != pm.end()) {
maxi = max(maxi, i - pm[curr - target]);
}
pm[curr] = i;
}
return maxi == -1 ? -1 : n - maxi;
}
Codevilla numeric questโ
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
#include <bits/stdc++.h>
using namespace std;
string ltrim(const string &);
string rtrim(const string &);
/*
* Complete the 'minNumberOfLights' function below.
*
* The function is expected to return an INTEGER.
* The function accepts following parameters:
* 1. INTEGER_ARRAY A
* 2. INTEGER P
*/
int minNumberOfLights(vector<int> A, int P) {
int n = A.size();
int lamps_on = 0;
int i = 0;
while (i < n) {
int furthest_cover = -1;
for (int j = max(0, i - P + 1); j < std::min(n, i + P); ++j) {
if (A[j] == 1) {
furthest_cover = j + P - 1;
}
}
if (furthest_cover == -1) {
return -1;
}
lamps_on++;
i = furthest_cover + 1;
}
return lamps_on;
}
Luminous Passage Quest
Salesforce โ
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
#include <iostream>
#include <set>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
string strip(const string& h) {
if (h.substr(0, 4) == "www.") return h.substr(4);
if (h.substr(0, 4) == "ww2.") return h.substr(4);
if (h.substr(0, 4) == "web.") return h.substr(4);
return h;
}
string extractDomain(const string& u) {
string p_http = "http://";
string p_https = "https://";
size_t p_pos = string::npos;
if (u.substr(0, p_http.size()) == p_http) p_pos = p_http.size();
else if (u.substr(0, p_https.size()) == p_https) p_pos = p_https.size();
if (p_pos == string::npos) return "";
size_t e_pos = u.find('/', p_pos);
string h = (e_pos == string::npos) ? u.substr(p_pos) : u.substr(p_pos, e_pos - p_pos);
return strip(h);
}
vector<string> extractURLs(const string& l) {
vector<string> urls;
size_t s = 0;
while ((s = l.find("http://", s)) != string::npos || (s = l.find("https://", s)) != string::npos) {
size_t e = l.find_first_of(" \n)", s);
if (e == string::npos) e = l.length();
urls.push_back(l.substr(s, e - s));
s = e;
}
return urls;
}
string getPotentialDomains(const vector<string>& lines) {
set<string> d_set;
for (const string& l : lines) {
vector<string> urls = extractURLs(l);
for (const string& u : urls) {
string d = extractDomain(u);
if (!d.empty() && count(d.begin(), d.end(), '.') >= 1) d_set.insert(d);
}
}
vector<string> sorted_d(d_set.begin(), d_set.end());
string res;
for (size_t i = 0; i < sorted_d.size(); ++i) {
if (i > 0) res += ";";
res += sorted_d[i];
}
return res;
}
Standard Chartered โ
#include <set>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
string strip(const string& h) {
if (h.substr(0, 4) == "www.") return h.substr(4);
if (h.substr(0, 4) == "ww2.") return h.substr(4);
if (h.substr(0, 4) == "web.") return h.substr(4);
return h;
}
string extractDomain(const string& u) {
string p_http = "http://";
string p_https = "https://";
size_t p_pos = string::npos;
if (u.substr(0, p_http.size()) == p_http) p_pos = p_http.size();
else if (u.substr(0, p_https.size()) == p_https) p_pos = p_https.size();
if (p_pos == string::npos) return "";
size_t e_pos = u.find('/', p_pos);
string h = (e_pos == string::npos) ? u.substr(p_pos) : u.substr(p_pos, e_pos - p_pos);
return strip(h);
}
vector<string> extractURLs(const string& l) {
vector<string> urls;
size_t s = 0;
while ((s = l.find("http://", s)) != string::npos || (s = l.find("https://", s)) != string::npos) {
size_t e = l.find_first_of(" \n)", s);
if (e == string::npos) e = l.length();
urls.push_back(l.substr(s, e - s));
s = e;
}
return urls;
}
string getPotentialDomains(const vector<string>& lines) {
set<string> d_set;
for (const string& l : lines) {
vector<string> urls = extractURLs(l);
for (const string& u : urls) {
string d = extractDomain(u);
if (!d.empty() && count(d.begin(), d.end(), '.') >= 1) d_set.insert(d);
}
}
vector<string> sorted_d(d_set.begin(), d_set.end());
string res;
for (size_t i = 0; i < sorted_d.size(); ++i) {
if (i > 0) res += ";";
res += sorted_d[i];
}
return res;
}
Standard Chartered โ
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Company Name: NTT
Role: Java Developer
Batch eligible: 2023 and 2024 grads
Apply: https://nttdata.eightfold.ai/careers?pid=563327919479126&domain=nttdata.com
Role: Java Developer
Batch eligible: 2023 and 2024 grads
Apply: https://nttdata.eightfold.ai/careers?pid=563327919479126&domain=nttdata.com
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Capgemini
Software Engineer || Capgemini Exceller 2023-24
Capgemini ยท Mumbai, Pune, Bangalore
Full Time
https://app.joinsuperset.com/join/#/signup/student/jobprofiles/6e4f8e33-c0a0-4348-83af-66cd8aa8ff9e
Software Engineer || Capgemini Exceller 2023-24
Capgemini ยท Mumbai, Pune, Bangalore
Full Time
https://app.joinsuperset.com/join/#/signup/student/jobprofiles/6e4f8e33-c0a0-4348-83af-66cd8aa8ff9e
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
๐Omnicell is hiring for Engineer I, Software
Experience: 0 - 2 year's
Expected Salary: 9-14 LPA
Apply here: https://www.linkedin.com/jobs/view/4035503619/?alternateChannel=search
Experience: 0 - 2 year's
Expected Salary: 9-14 LPA
Apply here: https://www.linkedin.com/jobs/view/4035503619/?alternateChannel=search
๐1
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
๐1
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Smaclify WOW
Intern-Growth | Fresher | Bengaluru
Click this link to view job description and apply. Please share this link if you know someone who would be a good fit for this position.Thank you.
import java.util.TreeSet;
public class Main {
public int TaichiAndLand(int n, int m, int[][] arr, int K) {
int maxSum = Integer.MIN_VALUE;
for (int top = 0; top < n; top++) {
int[] columnSum = new int[m];
for (int bottom = top; bottom < n; bottom++) {
for (int col = 0; col < m; col++) {
columnSum[col] += arr[bottom][col];
}
maxSum = Math.max(maxSum, solve(columnSum, K));
}
}
return maxSum;
}
private int solve(int[] nums, int K) {
int sum = 0;
int maxSum = Integer.MIN_VALUE;
TreeSet<Integer> cc = new TreeSet<>();
cc.add(0);
for (int num : nums) {
sum += num;
Integer prefix = cc.ceiling(sum - K);
if (prefix != null) {
maxSum = Math.max(maxSum, sum - prefix);
}
cc.add(sum);
}
return maxSum;
}
taichi and land โ
Probo(intern)
import java.util.*;
public class Main {
static class DSU {
int[] parent, size;
public DSU(int n) {
parent = new int[n];
size = new int[n];
for (int i = 0; i < n; i++) {
parent[i] = i;
size[i] = 1;
}
}
public int find(int x) {
if (parent[x] != x) {
parent[x] = find(parent[x]);
}
return parent[x];
}
public void union(int x, int y) {
int rootX = find(x);
int rootY = find(y);
if (rootX != rootY) {
if (size[rootX] < size[rootY]) {
parent[rootX] = rootY;
size[rootY] += size[rootX];
} else {
parent[rootY] = rootX;
size[rootX] += size[rootY];
}
}
}
}
public static int solution(int n, int p, int[][] programmers) {
DSU dsu = new DSU(n);
for (int i = 0; i < p; i++) {
int u = programmers[i][0];
int v = programmers[i][1];
dsu.union(u, v);
}
Map<Integer, Integer> componentSize = new HashMap<>();
for (int i = 0; i < n; i++) {
int root = dsu.find(i);
componentSize.put(root, componentSize.getOrDefault(root, 0) + 1);
}
long totalPairs = (long) n * (n - 1) / 2;
for (int size : componentSize.values()) {
totalPairs -= (long) size * (size - 1) / 2;
}
return (int) totalPairs;
}
Contest pair โ
Probo (intern)