๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
#include<bits/stdc++.h>
#define pb push_back
#define int long long
using namespace std;
const int mod = 1e9+7;
const int N = 1e5 + 5;
const int K = 18;
vector<int> get(vector<int> d){
map<int, int> cnt, swp;
for(int i = 0; i < d.size(); i++){
cnt[d[i]]++;
}
vector<int> miss;
for(int i = 1; i <= d.size(); i++){
if(!cnt[i]) miss.pb(i);
}
vector<int> ans = d;
int ind = 0;
for(int i = 0; i < d.size(); i++){
if(cnt[d[i]] > 1 || d[i] > d.size()){
if(d[i] < miss[ind] && !swp[d[i]]){
swp[d[i]] = 1;
}
else{
ans[i] = miss[ind];
ind++;
cnt[d[i]]--;
}
}
}
return ans;
}
int32_t main(){
cin.tie(0); cout.tie(0);
ios_base::sync_with_stdio(false);
int n;
cin>>n;
vector<int> a(n);
for(int i = 0; i < n; i++){
cin>>a[i];
}
vector<int> ans = get(a);
for(int i = 0; i < n; i++){
cout<<ans[i]<<endl;
}
return 0;
}
DE Shaw โ
#define pb push_back
#define int long long
using namespace std;
const int mod = 1e9+7;
const int N = 1e5 + 5;
const int K = 18;
vector<int> get(vector<int> d){
map<int, int> cnt, swp;
for(int i = 0; i < d.size(); i++){
cnt[d[i]]++;
}
vector<int> miss;
for(int i = 1; i <= d.size(); i++){
if(!cnt[i]) miss.pb(i);
}
vector<int> ans = d;
int ind = 0;
for(int i = 0; i < d.size(); i++){
if(cnt[d[i]] > 1 || d[i] > d.size()){
if(d[i] < miss[ind] && !swp[d[i]]){
swp[d[i]] = 1;
}
else{
ans[i] = miss[ind];
ind++;
cnt[d[i]]--;
}
}
}
return ans;
}
int32_t main(){
cin.tie(0); cout.tie(0);
ios_base::sync_with_stdio(false);
int n;
cin>>n;
vector<int> a(n);
for(int i = 0; i < n; i++){
cin>>a[i];
}
vector<int> ans = get(a);
for(int i = 0; i < n; i++){
cout<<ans[i]<<endl;
}
return 0;
}
DE Shaw โ
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
using namespace std;
void topologicalSort(int node, vector<bool>& visited, stack<int>& topoStack, const vector<vector<int>>& adj) {
visited[node] = true;
for (int neighbor : adj[node]) {
if (!visited[neighbor]) {
topologicalSort(neighbor, visited, topoStack, adj);
}
}
topoStack.push(node);
}
int getMaxPhotoBeauty(int city_nodes, const vector<int>& photo_beauty, const vector<pair<int, int>>& edges) {
vector<vector<int>> adj(city_nodes + 1);
for (const auto& edge : edges) {
adj[edge.first].push_back(edge.second);
}
stack<int> topoStack;
vector<bool> visited(city_nodes + 1, false);
for (int i = 1; i <= city_nodes; ++i) {
if (!visited[i]) {
topologicalSort(i, visited, topoStack, adj);
}
}
vector<int> dp(city_nodes + 1, 0);
for (int i = 1; i <= city_nodes; ++i) {
dp[i] = photo_beauty[i - 1];
}
int max_beauty = 0;
while (!topoStack.empty()) {
int node = topoStack.top();
topoStack.pop();
for (int neighbor : adj[node]) {
if (dp[neighbor] < dp[node] + photo_beauty[neighbor - 1]) {
dp[neighbor] = dp[node] + photo_beauty[neighbor - 1];
}
}
max_beauty = max(max_beauty, dp[node]);
}
return max_beauty;
}
DE Shaw โ
#include <vector>
#include <algorithm>
#include <stack>
using namespace std;
void topologicalSort(int node, vector<bool>& visited, stack<int>& topoStack, const vector<vector<int>>& adj) {
visited[node] = true;
for (int neighbor : adj[node]) {
if (!visited[neighbor]) {
topologicalSort(neighbor, visited, topoStack, adj);
}
}
topoStack.push(node);
}
int getMaxPhotoBeauty(int city_nodes, const vector<int>& photo_beauty, const vector<pair<int, int>>& edges) {
vector<vector<int>> adj(city_nodes + 1);
for (const auto& edge : edges) {
adj[edge.first].push_back(edge.second);
}
stack<int> topoStack;
vector<bool> visited(city_nodes + 1, false);
for (int i = 1; i <= city_nodes; ++i) {
if (!visited[i]) {
topologicalSort(i, visited, topoStack, adj);
}
}
vector<int> dp(city_nodes + 1, 0);
for (int i = 1; i <= city_nodes; ++i) {
dp[i] = photo_beauty[i - 1];
}
int max_beauty = 0;
while (!topoStack.empty()) {
int node = topoStack.top();
topoStack.pop();
for (int neighbor : adj[node]) {
if (dp[neighbor] < dp[node] + photo_beauty[neighbor - 1]) {
dp[neighbor] = dp[node] + photo_beauty[neighbor - 1];
}
}
max_beauty = max(max_beauty, dp[node]);
}
return max_beauty;
}
DE Shaw โ
int findMaxUses(vector<int>& costs, vector<int>& uses, int budget) {
int n = costs.size();
if (n < 2) {
return -1;
}
vector<pair<int, int>> ft;
for (int i = 0; i < n; ++i) {
ft.push_back({costs[i], uses[i]});
}
sort(ft.begin(), ft.end());
int maxUses = -1;
int i = 0;
while (i < n) {
int j = i + 1;
while (j < n) {
int totalCost = ft[i].first + ft[j].first;
if (totalCost <= budget) {
int totalUses = ft[i].second + ft[j].second;
maxUses = max(maxUses, totalUses);
++j;
} else {
break;
}
}
++i;
}
return maxUses;
}
DE Shaw โ
int n = costs.size();
if (n < 2) {
return -1;
}
vector<pair<int, int>> ft;
for (int i = 0; i < n; ++i) {
ft.push_back({costs[i], uses[i]});
}
sort(ft.begin(), ft.end());
int maxUses = -1;
int i = 0;
while (i < n) {
int j = i + 1;
while (j < n) {
int totalCost = ft[i].first + ft[j].first;
if (totalCost <= budget) {
int totalUses = ft[i].second + ft[j].second;
maxUses = max(maxUses, totalUses);
++j;
} else {
break;
}
}
++i;
}
return maxUses;
}
DE Shaw โ
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;
int dfs(int node, vector<int>& likes, vector<int>& visited, vector<int>& stack, vector<int>& index, int& counter) {
if (visited[node] == 2) {
return 0;
}
if (visited[node] == 1) {
return counter - index[node];
}
visited[node] = 1;
stack.push_back(node);
index[node] = counter++;
int cycle_length = dfs(likes[node], likes, visited, stack, index, counter);
if (cycle_length) {
return cycle_length;
}
stack.pop_back();
visited[node] = 2;
counter--;
return 0;
}
int maxCEOsAttend(int num, vector<int>& likes) {
vector<int> visited(num, 0);
vector<int> stack;
vector<int> index(num, 0);
int counter = 0;
int max_cycle_length = 0;
for (int i = 0; i < num; ++i) {
if (!visited[i]) {
int cycle_length = dfs(i, likes, visited, stack, index, counter);
max_cycle_length = max(max_cycle_length, cycle_length);
}
}
return max_cycle_length;
}
int main() {
int num;
cin >> num;
vector<int> likes(num);
for (int i = 0; i < num; ++i) {
cin >> likes[i];
likes[i]--;
}
cout << maxCEOsAttend(num, likes) << endl;
return 0;
}
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;
int dfs(int node, vector<int>& likes, vector<int>& visited, vector<int>& stack, vector<int>& index, int& counter) {
if (visited[node] == 2) {
return 0;
}
if (visited[node] == 1) {
return counter - index[node];
}
visited[node] = 1;
stack.push_back(node);
index[node] = counter++;
int cycle_length = dfs(likes[node], likes, visited, stack, index, counter);
if (cycle_length) {
return cycle_length;
}
stack.pop_back();
visited[node] = 2;
counter--;
return 0;
}
int maxCEOsAttend(int num, vector<int>& likes) {
vector<int> visited(num, 0);
vector<int> stack;
vector<int> index(num, 0);
int counter = 0;
int max_cycle_length = 0;
for (int i = 0; i < num; ++i) {
if (!visited[i]) {
int cycle_length = dfs(i, likes, visited, stack, index, counter);
max_cycle_length = max(max_cycle_length, cycle_length);
}
}
return max_cycle_length;
}
int main() {
int num;
cin >> num;
vector<int> likes(num);
for (int i = 0; i < num; ++i) {
cin >> likes[i];
likes[i]--;
}
cout << maxCEOsAttend(num, likes) << endl;
return 0;
}
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Company Name: Blinkit
๐ Job Title: iOS Intern
โ๐ป YOE: 2025 and 2026 grads
โก๏ธ Apply: https://docs.google.com/forms/d/e/1FAIpQLSfD8_X1lyR5SA-G9YgwteAE0TkrVNFs5uDsh73cFH7rw0jJRA/viewform
Please do share in your college grps and in case you are applying please react on this post:) ๐โค๏ธ
๐ Job Title: iOS Intern
โ๐ป YOE: 2025 and 2026 grads
โก๏ธ Apply: https://docs.google.com/forms/d/e/1FAIpQLSfD8_X1lyR5SA-G9YgwteAE0TkrVNFs5uDsh73cFH7rw0jJRA/viewform
Please do share in your college grps and in case you are applying please react on this post:) ๐โค๏ธ
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
A venture capital is hiring intern (non-tech)
Apply - https://docs.google.com/forms/d/e/1FAIpQLSdMCd8azH3q26okPzZJNQJQbhyluZ1l7PAPe-mM3CU9ZqawgA/viewform
Apply - https://docs.google.com/forms/d/e/1FAIpQLSdMCd8azH3q26okPzZJNQJQbhyluZ1l7PAPe-mM3CU9ZqawgA/viewform
Google Docs
VC Internship application
Ready to take the first step towards a career in venture capital?
There will be "down-days" with minimal work and some "busy days" with urgent deliverables. If your English spelling/grammar is excellent, that's great. If not, install browser extensionsโฆ
There will be "down-days" with minimal work and some "busy days" with urgent deliverables. If your English spelling/grammar is excellent, that's great. If not, install browser extensionsโฆ
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
https://www.linkedin.com/posts/rashmisnaidu_fill-target-in-india-apprenticeship-program-activity-7214115991406936064-WZBF?utm_source=share&utm_medium=member_android
Apply link : https://forms.office.com/pages/responsepage.aspx?id=88CH9iaRvUW5lLlt-KGckQO_ffnVkDZDmXEu9d1eLi9UMTU1RDI1MDcyNFJaUEc4WUNVV0dUQjRESi4u
Apply link : https://forms.office.com/pages/responsepage.aspx?id=88CH9iaRvUW5lLlt-KGckQO_ffnVkDZDmXEu9d1eLi9UMTU1RDI1MDcyNFJaUEc4WUNVV0dUQjRESi4u
Linkedin
Fill | Target in India Apprenticeship Program - 2024 | Rashmi Saravanan | 62 comments
Target India Apprenticeship Program
** It's not referral program , you directly apply on the link provided below **
Apprentice โ Tech (Engineering Graduates)
Apprentice โ Retail Ops (Graduates in BA, BCOM, BSC, BBA, etc.)
Apprentice โ Analytics (MBA/PGDM)โฆ
** It's not referral program , you directly apply on the link provided below **
Apprentice โ Tech (Engineering Graduates)
Apprentice โ Retail Ops (Graduates in BA, BCOM, BSC, BBA, etc.)
Apprentice โ Analytics (MBA/PGDM)โฆ
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Company Name: Hashicorp
๐ Job Title: Software Engineering Intern
โ๐ป YOE: 2025 and 2026 grads
โก๏ธ Apply: https://www.hashicorp.com/career/6050047?gh_src=a8bc2ad21
Please do share in your college grps and in case you are applying please react on this post:) ๐โค๏ธ
๐ Job Title: Software Engineering Intern
โ๐ป YOE: 2025 and 2026 grads
โก๏ธ Apply: https://www.hashicorp.com/career/6050047?gh_src=a8bc2ad21
Please do share in your college grps and in case you are applying please react on this post:) ๐โค๏ธ
class UserMainCode(object):
@classmethod
def strongString(cls, input1, input2):
n = len(input2)
min_strings = []
for i in range(min(input1, n)):
distribution = [''] * input1
for j in range(n):
distribution[j % input1] += input2[j]
min_string = min(distribution)
min_strings.append(min_string)
result = max(min_strings)
return result
Game of String Distribution โ
@classmethod
def strongString(cls, input1, input2):
n = len(input2)
min_strings = []
for i in range(min(input1, n)):
distribution = [''] * input1
for j in range(n):
distribution[j % input1] += input2[j]
min_string = min(distribution)
min_strings.append(min_string)
result = max(min_strings)
return result
Game of String Distribution โ
Mathematical Equation โ
def profitable_project_pairs(profit, implementationCost):
n = len(profit)
net_profit = [profit[i] - implementationCost[i] for i in range(n)]
net_profit.sort()
count = 0
left = 0
right = n - 1
while left < right:
if net_profit[left] + net_profit[right] > 0:
count += (right - left)
right -= 1
else:
left += 1
return count
Profitable project pairs โ
Workspan
n = len(profit)
net_profit = [profit[i] - implementationCost[i] for i in range(n)]
net_profit.sort()
count = 0
left = 0
right = n - 1
while left < right:
if net_profit[left] + net_profit[right] > 0:
count += (right - left)
right -= 1
else:
left += 1
return count
Profitable project pairs โ
Workspan
๐1