๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
const int INF = numeric_limits<int>::max();
vector<int> getPredecessors(int graph_nodes, const vector<int> &graph_from, const vector<int> &graph_to, const vector<int> &graph_weight, int c)
{
vector<vector<pair<int, int>>> graph(graph_nodes + 1);
for (size_t i = 0; i < graph_from.size(); ++i)
{
int u = graph_from[i];
int v = graph_to[i];
int w = graph_weight[i];
graph[u].emplace_back(v, w);
graph[v].emplace_back(u, w);
}
vector<int> dist(graph_nodes + 1, INF);
vector<set<int>> predecessors(graph_nodes + 1);
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> min_heap;
dist[c] = 0;
min_heap.emplace(0, c);
while (!min_heap.empty())
{
int d = min_heap.top().first;
int u = min_heap.top().second;
min_heap.pop();
if (d > dist[u])
continue;
for (const auto &edge : graph[u])
{
int v = edge.first;
int weight = edge.second;
if (dist[u] + weight <= dist[v])
{
if (dist[u] + weight < dist[v])
{
dist[v] = dist[u] + weight;
predecessors[v].clear();
min_heap.emplace(dist[v], v);
}
if (u != c)
predecessors[v].insert(u);
predecessors[v].insert(predecessors[u].begin(), predecessors[u].end());
}
}
}
vector<int> predecessor_count(graph_nodes + 1, 0);
predecessor_count[c] = 0;
for (int i = 1; i <= graph_nodes; ++i)
predecessor_count[i] = predecessors[i].size();
return vector<int>(predecessor_count.begin() + 1, predecessor_count.end());
}
Count of predecessors โ
HP(FTE)
vector<int> getPredecessors(int graph_nodes, const vector<int> &graph_from, const vector<int> &graph_to, const vector<int> &graph_weight, int c)
{
vector<vector<pair<int, int>>> graph(graph_nodes + 1);
for (size_t i = 0; i < graph_from.size(); ++i)
{
int u = graph_from[i];
int v = graph_to[i];
int w = graph_weight[i];
graph[u].emplace_back(v, w);
graph[v].emplace_back(u, w);
}
vector<int> dist(graph_nodes + 1, INF);
vector<set<int>> predecessors(graph_nodes + 1);
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> min_heap;
dist[c] = 0;
min_heap.emplace(0, c);
while (!min_heap.empty())
{
int d = min_heap.top().first;
int u = min_heap.top().second;
min_heap.pop();
if (d > dist[u])
continue;
for (const auto &edge : graph[u])
{
int v = edge.first;
int weight = edge.second;
if (dist[u] + weight <= dist[v])
{
if (dist[u] + weight < dist[v])
{
dist[v] = dist[u] + weight;
predecessors[v].clear();
min_heap.emplace(dist[v], v);
}
if (u != c)
predecessors[v].insert(u);
predecessors[v].insert(predecessors[u].begin(), predecessors[u].end());
}
}
}
vector<int> predecessor_count(graph_nodes + 1, 0);
predecessor_count[c] = 0;
for (int i = 1; i <= graph_nodes; ++i)
predecessor_count[i] = predecessors[i].size();
return vector<int>(predecessor_count.begin() + 1, predecessor_count.end());
}
Count of predecessors โ
HP(FTE)
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
#include <iostream>
#include <vector>
using namespace std;
class UnionFind {
public:
vector<int> parent, rank, size;
UnionFind(int n) : parent(n), rank(n, 1), size(n, 1) {
for (int i = 0; i < n; ++i) {
parent[i] = i;
}
}
int find(int x) {
if (parent[x] != x) {
parent[x] = find(parent[x]);
}
return parent[x];
}
void unionSets(int x, int y) {
int rootX = find(x);
int rootY = find(y);
if (rootX != rootY) {
if (rank[rootX] > rank[rootY]) {
parent[rootY] = rootX;
size[rootX] += size[rootY];
} else if (rank[rootX] < rank[rootY]) {
parent[rootX] = rootY;
size[rootY] += size[rootX];
} else {
parent[rootY] = rootX;
size[rootX] += size[rootY];
rank[rootX]++;
}
}
}
int getSize(int x) {
int rootX = find(x);
return size[rootX];
}
};
long long countPairs(int n, int k, vector<int>& u, vector<int>& v) {
UnionFind uf(n);
for (int i = 0; i < k; ++i) {
uf.unionSets(u[i], v[i]);
}
long long totalPairs = (long long)n * (n - 1) / 2;
vector<bool> visited(n, false);
for (int i = 0; i < n; ++i) {
int root = uf.find(i);
if (!visited[root]) {
visited[root] = true;
int clusterSize = uf.getSize(i);
if (clusterSize > 1) {
totalPairs -= (long long)clusterSize * (clusterSize - 1) / 2;
}
}
}
return totalPairs;
}
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct Fenwick {
int n;
vector<long long> bit;
Fenwick(int a) {
n = a;
bit.resize(n + 1);
}
void update(int ind, long long val) {
for (; ind <= n; ind += (ind & (-ind)))
bit[ind] += val;
}
long long query(int ind) {
long long res = 0;
for (; ind; ind -= (ind & (-ind)))
res += bit[ind];
return res;
}
};
long long solve(vector<int>& v, int l, int r) {
long long res = 0;
int n = v.size();
Fenwick fwn(n);
for (int i = l; i <= r; i++) {
res += fwn.query(n) - fwn.query(v[i]);
fwn.update(v[i], 1);
}
return res;
}
long long getMinSwap(vector<int> arr) {
int n = arr.size();
vector<int> cnt(n);
for (int i = 0; i < n; ++i) {
cnt[i] = __builtin_popcount(arr[i]);
}
vector<pair<int, int>> temp(n);
for (int i = 0; i < n; ++i) {
temp[i] = {arr[i], i};
}
sort(temp.begin(), temp.end());
vector<int> val(n);
int ct = 1;
for (int i = 0; i < n; ++i) {
val[temp[i].second] = ct++;
}
vector<int> v = val;
bool chk = true;
int ls = 0;
for (int i = 1; i < n; ++i) {
if (cnt[i] == cnt[i - 1]) {
continue;
} else {
sort(v.begin() + ls, v.begin() + i);
ls = i;
}
}
sort(v.begin() + ls, v.end());
for (int i = 0; i < n; ++i) {
if (v[i] != (i + 1)) {
chk = false;
break;
}
}
if (!chk) {
return -1;
} else {
long long res = 0;
ls = 0;
for (int i = 1; i < n; ++i) {
if (cnt[i] == cnt[i - 1]) {
continue;
} else {
res += solve(val, ls, i - 1);
ls = i;
}
}
res += solve(val, ls, n - 1);
return res;
}
}
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Company Name: Clearfeed
Role: Software Engineer Intern
Batch eligible: 2025 grads only
Apply: https://clearfeed.keka.com/careers/jobdetails/798
Role: Software Engineer Intern
Batch eligible: 2025 grads only
Apply: https://clearfeed.keka.com/careers/jobdetails/798
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
long long anser(vector<int>& arr, int i, vector<long long>& dp) {
if (i >= arr.size()) {
return -1;
}
if (dp[i] != -1) {
return dp[i];
}
int ans=anser(arr,i+1,dp);
return max(ans,max(ans|arr[i],arr[i]));
}
long long answer(vector<int>& arr) {
int n = arr.size();
vector<long long> dp(n, -1);
return anser(arr, 0, dp);
}
OR BITโ
#include <iostream>
#include <vector>
using namespace std;
pair<int, int> urgent(const vector<int>& arr, int n) {
vector<int> freq(n + 1, 0);
int duplicate = -1, missing = -1;
for (int i = 0; i < n; i++) {
freq[arr[i]]++;
}
for (int i = 1; i <= n; i++) {
if (freq[i] == 0) {
missing = i;
} else if (freq[i] > 1) {
duplicate = i;
}
}
if (duplicate != -1 && missing != -1) {
return {duplicate, missing};
} else {
return {-1, -1};
}
}
Messed Up Array โ
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Gammaprep is hiring for Multiple roles
Remote Opportunity
8 - 9 LPA CTC
Apply Here : https://wellfound.com/jobs/3086112-data-analyst-at-gammaprep-com
Remote Opportunity
8 - 9 LPA CTC
Apply Here : https://wellfound.com/jobs/3086112-data-analyst-at-gammaprep-com
๐1
#include <iostream>
#include <vector>
using namespace std;
void solve(int N, const vector<int>& L, const vector<int>& R) {
vector<pair<int, int>> available_slots;
if (L[0] > 0) {
available_slots.push_back({0, L[0]});
}
for (int i = 1; i < N; ++i) {
if (R[i-1] < L[i]) {
available_slots.push_back({R[i-1], L[i]});
}
}
if (R[N-1] < 1000000000) {
available_slots.push_back({R[N-1], 1000000000});
}
if (available_slots.empty()) {
cout << "-1 -1" << endl;
} else {
for (const auto& slot : available_slots) {
cout << slot.first << " " << slot.second << " ";
}
cout << endl;
}
}
Available Time Frames โ
#include <vector>
using namespace std;
void solve(int N, const vector<int>& L, const vector<int>& R) {
vector<pair<int, int>> available_slots;
if (L[0] > 0) {
available_slots.push_back({0, L[0]});
}
for (int i = 1; i < N; ++i) {
if (R[i-1] < L[i]) {
available_slots.push_back({R[i-1], L[i]});
}
}
if (R[N-1] < 1000000000) {
available_slots.push_back({R[N-1], 1000000000});
}
if (available_slots.empty()) {
cout << "-1 -1" << endl;
} else {
for (const auto& slot : available_slots) {
cout << slot.first << " " << slot.second << " ";
}
cout << endl;
}
}
Available Time Frames โ
๐1
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Linkedin
#hiring #startuphiring #internship | Ravi Ahlawat | 61 comments
A friend is hiring 2 Founder Office Interns at a YC startup! ๐
๐ Looking for someone who can wear multiple hats and learn on-the-go with a proactive problem solving mindset with high velocity.
This role offers high ownership with a steep learning curveโฆ
๐ Looking for someone who can wear multiple hats and learn on-the-go with a proactive problem solving mindset with high velocity.
This role offers high ownership with a steep learning curveโฆ
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Company Name : Siemens
Scholarship for first year students from Government Colleges.
Entire Tuition Fee covered + Internship at Siemens also
Link : https://www.siemens.com/in/en/company/sustainability/corporate-citizenship/siemens-scholarship-program.html
Last Date is September 15. Apply early.
Share with first year students from your college.
Scholarship for first year students from Government Colleges.
Entire Tuition Fee covered + Internship at Siemens also
Link : https://www.siemens.com/in/en/company/sustainability/corporate-citizenship/siemens-scholarship-program.html
Last Date is September 15. Apply early.
Share with first year students from your college.
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
QBrainX is hiring for ServiceNow Opportunity for 2018 to 2023 passouts
Send resume to : sona.sekar@qbrainx.com
Send resume to : sona.sekar@qbrainx.com
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Rapido Intern Product Management
https://docs.google.com/forms/d/e/1FAIpQLSfuJQjLs0vPGkJTuUY7j-AX0cx0sSLJGM8XpDw-MpoVh6Pc7A/viewform
https://docs.google.com/forms/d/e/1FAIpQLSfuJQjLs0vPGkJTuUY7j-AX0cx0sSLJGM8XpDw-MpoVh6Pc7A/viewform
๐1
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Python Developer Trainee
Location : Pune
Interested candidate send your Resume
aghaavte@inferyx.com
Location : Pune
Interested candidate send your Resume
aghaavte@inferyx.com
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Deadline 3 September
https://docs.google.com/forms/d/e/1FAIpQLSe7uqxivfcfJQNYJHczImAXVYX66ZWFR12ir7_ScOmATJ7Mrg/viewform
https://docs.google.com/forms/d/e/1FAIpQLSe7uqxivfcfJQNYJHczImAXVYX66ZWFR12ir7_ScOmATJ7Mrg/viewform
โค3
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Company Name : UST Global
D3 Hackathon 2024
Batch : All Engineering - BTech and MTech
Prizes worth 19 Lakhs to be won + PPO for top performers
Link to register : https://p.hck.re/hDC6
Last Date to register is September 4.
D3 Hackathon 2024
Batch : All Engineering - BTech and MTech
Prizes worth 19 Lakhs to be won + PPO for top performers
Link to register : https://p.hck.re/hDC6
Last Date to register is September 4.
HackerEarth
UST D3CODE Hackathon'24 on HackerEarth
D3CODE, UST presents an exciting opportunity for tech enthusiasts to demonstrate their passion for innovation, problem-solving, design thinking, and programming skills, with the chance to win incredible prizes. D3CODE consists of two main events: regionalโฆ
๐1