๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
int minimize_difference(int N, vector<int>& A, int K, vector<int>& operand) { vector<vector<int>> possible_values(N); for (int idx = 0; idx < N; ++idx) { set<int> values; for (int mask = 0; mask < (1 << K); ++mask) { intโฆ
from itertools import product
from collections import defaultdict
def minimize_difference(N, A, K, operand):
possible_values = []
for a in A:
values = set()
for mask in range(1 << K):
new_value = a
for i in range(K):
if mask & (1 << i):
new_value ^= operand[i]
values.add(new_value)
possible_values.append(sorted(values))
all_values = []
for i, values in enumerate(possible_values):
for value in values:
all_values.append((value, i))
all_values.sort()
count = defaultdict(int)
left = 0
min_range = float('inf')
distinct_count = 0
for right, (value, i) in enumerate(all_values):
if count[i] == 0:
distinct_count += 1
count[i] += 1
while distinct_count == N:
min_range = min(min_range, all_values[right][0] - all_values[left][0])
left_value, left_index = all_values[left]
count[left_index] -= 1
if count[left_index] == 0:
distinct_count -= 1
left += 1
return min_range
Xor on Array โ
from collections import defaultdict
def minimize_difference(N, A, K, operand):
possible_values = []
for a in A:
values = set()
for mask in range(1 << K):
new_value = a
for i in range(K):
if mask & (1 << i):
new_value ^= operand[i]
values.add(new_value)
possible_values.append(sorted(values))
all_values = []
for i, values in enumerate(possible_values):
for value in values:
all_values.append((value, i))
all_values.sort()
count = defaultdict(int)
left = 0
min_range = float('inf')
distinct_count = 0
for right, (value, i) in enumerate(all_values):
if count[i] == 0:
distinct_count += 1
count[i] += 1
while distinct_count == N:
min_range = min(min_range, all_values[right][0] - all_values[left][0])
left_value, left_index = all_values[left]
count[left_index] -= 1
if count[left_index] == 0:
distinct_count -= 1
left += 1
return min_range
Xor on Array โ
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Vahan hiring for below roles :
SDE Intern : 2025/2024 batches
SDE l : 2024/2023/2022 batches
SDE ll : 2022/2021 and before batches
Referral Form :
https://forms.gle/n8z8owcZZgHddoMt8
SDE Intern : 2025/2024 batches
SDE l : 2024/2023/2022 batches
SDE ll : 2022/2021 and before batches
Referral Form :
https://forms.gle/n8z8owcZZgHddoMt8
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Codefeast is hiring for above roles :
2027 , 2026 , 2025 passout batches eligible
Available for 6 months remote full time intern
Apply Form : https://docs.google.com/forms/d/e/1FAIpQLSfCEQRLNw1fxO2L1HyzT38R34Wk2rjkqL0FO7RZG88WC6QrFg/viewform
2027 , 2026 , 2025 passout batches eligible
Available for 6 months remote full time intern
Apply Form : https://docs.google.com/forms/d/e/1FAIpQLSfCEQRLNw1fxO2L1HyzT38R34Wk2rjkqL0FO7RZG88WC6QrFg/viewform
Google Docs
Codefeast | Trainer Applications | Remote
Codefeast is hiring undergrads and freshers for the following remote profiles.
1) ๐๐๐๐ ๐๐๐ง๐ญ๐จ๐ซ - Full time 10am - 6pm - 25k-35k
๐๐ฒ๐ฅ๐ฅ๐๐๐ฎ๐ฌ - https://docs.google.com/spreadsheets/d/1vhHHmJoSjMWJ993SClP5camm1ccDWpIn/edit?usp=sharing&ouid=115627370971383014274โฆ
1) ๐๐๐๐ ๐๐๐ง๐ญ๐จ๐ซ - Full time 10am - 6pm - 25k-35k
๐๐ฒ๐ฅ๐ฅ๐๐๐ฎ๐ฌ - https://docs.google.com/spreadsheets/d/1vhHHmJoSjMWJ993SClP5camm1ccDWpIn/edit?usp=sharing&ouid=115627370971383014274โฆ
๐1
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
CBTS hiring for Associate Software Engineer
2024/2023/2022 passouts
Chennai / Bangalore / Gurgaon
https://recruiting.adp.com/srccar/public/RTI.home?c=2190231&d=altafiberJobs&rb=INDEED&r=5001058832806#/
2024/2023/2022 passouts
Chennai / Bangalore / Gurgaon
https://recruiting.adp.com/srccar/public/RTI.home?c=2190231&d=altafiberJobs&rb=INDEED&r=5001058832806#/
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
embedUR systems : Fresher Drive B.E / B.Tech 2024 Batch
Salary Remuneration:
Offered CTC: Up to 8 Lakhs
Apply Form : http://forms.office.com/r/2BB7XFaqFj
Salary Remuneration:
Offered CTC: Up to 8 Lakhs
Apply Form : http://forms.office.com/r/2BB7XFaqFj
Office
Please fill out this form
๐1
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
int main() {
int n, m;
cin >> n >> m;
vector<int> ratings(n);
for (int i = 0; i < n; ++i) {
cin >> ratings[i];
}
sort(ratings.begin(), ratings.end());
vector<int> dp(n + 1, 0);
int maxPlayers = 0;
vector<vector<int>> dp2(m + 1, vector<int>(n + 1, 0));
for (int i = 1; i <= m; ++i) {
int left = 0;
for (int right = 1; right <= n; ++right) {
while (ratings[right - 1] - ratings[left] > 5) {
++left;
}
dp2[i][right] = max(dp2[i][right - 1], dp2[i - 1][left] + (right - left));
maxPlayers = max(maxPlayers, dp2[i][right]);
}
}
cout << maxPlayers << endl;
return 0;
}
Uber โ
int n, m;
cin >> n >> m;
vector<int> ratings(n);
for (int i = 0; i < n; ++i) {
cin >> ratings[i];
}
sort(ratings.begin(), ratings.end());
vector<int> dp(n + 1, 0);
int maxPlayers = 0;
vector<vector<int>> dp2(m + 1, vector<int>(n + 1, 0));
for (int i = 1; i <= m; ++i) {
int left = 0;
for (int right = 1; right <= n; ++right) {
while (ratings[right - 1] - ratings[left] > 5) {
++left;
}
dp2[i][right] = max(dp2[i][right - 1], dp2[i - 1][left] + (right - left));
maxPlayers = max(maxPlayers, dp2[i][right]);
}
}
cout << maxPlayers << endl;
return 0;
}
Uber โ
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
public int minChargingSpeed(int[] evBatteries, int totalHours) {
int left = 1;
int right = getMax(evBatteries);
while (left < right) {
int mid = left + (right - left) / 2;
if (canChargeAll(evBatteries, mid, totalHours)) {
right = mid;
} else {
left = mid + 1;
}
}
return left;
}
private int getMax(int[] evBatteries) {
int max = 0;
for (int battery : evBatteries) {
max = Math.max(max, battery);
}
return max;
}
private boolean canChargeAll(int[] evBatteries, int speed, int totalHours) {
int hoursNeeded = 0;
for (int battery : evBatteries) {
hoursNeeded += (battery + speed - 1) / speed;
}
return hoursNeeded <= totalHours;
}
Uber โ
int left = 1;
int right = getMax(evBatteries);
while (left < right) {
int mid = left + (right - left) / 2;
if (canChargeAll(evBatteries, mid, totalHours)) {
right = mid;
} else {
left = mid + 1;
}
}
return left;
}
private int getMax(int[] evBatteries) {
int max = 0;
for (int battery : evBatteries) {
max = Math.max(max, battery);
}
return max;
}
private boolean canChargeAll(int[] evBatteries, int speed, int totalHours) {
int hoursNeeded = 0;
for (int battery : evBatteries) {
hoursNeeded += (battery + speed - 1) / speed;
}
return hoursNeeded <= totalHours;
}
Uber โ
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
#include<bits/stdc++.h>
using namespace std;
vector<vector<int> > SolveTower (int N, vector<int> a) {
// Write your code here
vector<vector<int> > ans;
int done = N;
priority_queue<int> pq;
for(auto x: a){
pq.push(x);
vector<int> aux;
while(!pq.empty() && pq.top() == done){
aux.push_back(done);
pq.pop();
done--;
}
ans.push_back(aux);
}
sort(a.begin(), a.end());
a.resize(unique(a.begin(), a.end()) - a.begin());
assert(a.size() == N);
return ans;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int N;
cin >> N;
assert(1 <= N && N <= 1e6);
vector<int> a(N);
for(int i_a = 0; i_a < N; i_a++)
{
cin >> a[i_a];
}
vector<vector<int> > out_;
out_ = SolveTower(N, a);
for(int i = 0; i < out_.size(); i++){
for(int j = 0; j < out_[i].size(); j++){
cout << out_[i][j] << " ";
}
cout << "\n";
}
}
Uber โ
using namespace std;
vector<vector<int> > SolveTower (int N, vector<int> a) {
// Write your code here
vector<vector<int> > ans;
int done = N;
priority_queue<int> pq;
for(auto x: a){
pq.push(x);
vector<int> aux;
while(!pq.empty() && pq.top() == done){
aux.push_back(done);
pq.pop();
done--;
}
ans.push_back(aux);
}
sort(a.begin(), a.end());
a.resize(unique(a.begin(), a.end()) - a.begin());
assert(a.size() == N);
return ans;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int N;
cin >> N;
assert(1 <= N && N <= 1e6);
vector<int> a(N);
for(int i_a = 0; i_a < N; i_a++)
{
cin >> a[i_a];
}
vector<vector<int> > out_;
out_ = SolveTower(N, a);
for(int i = 0; i < out_.size(); i++){
for(int j = 0; j < out_[i].size(); j++){
cout << out_[i][j] << " ";
}
cout << "\n";
}
}
Uber โ
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
public static String maskSensitiveInfo(String data) {
if (isEmail(data)) {
return maskEmail(data);
} else if (isPhoneNumber(data)) {
return maskPhoneNumber(data);
}
return data;
}
private static boolean isEmail(String data) {
return data.matches("^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}$");
}
private static boolean isPhoneNumber(String data) {
return data.matches("^[0-9().\\-+ ]{10,20}$");
}
private static String maskEmail(String email) {
email = email.toLowerCase();
String[] parts = email.split("@");
String local = parts[0];
String domain = parts[1];
if (local.length() > 2) {
local = local.charAt(0) + "*" + local.charAt(local.length() - 1);
} else {
local = local.charAt(0) + "*";
}
return local + "@" + domain;
}
private static String maskPhoneNumber(String phone) {
phone = phone.replaceAll("[^0-9]", "");
int len = phone.length();
String maskedPhone = "";
if (len == 10) {
maskedPhone = "###-###-" + phone.substring(6);
} else if (len == 11) {
maskedPhone = "+#-###-###-" + phone.substring(7);
} else if (len == 12) {
maskedPhone = "+##-###-###-" + phone.substring(8);
} else if (len == 13) {
maskedPhone = "+###-###-###-" + phone.substring(9);
}
return maskedPhone;
}
Protecting Personal Information โ
if (isEmail(data)) {
return maskEmail(data);
} else if (isPhoneNumber(data)) {
return maskPhoneNumber(data);
}
return data;
}
private static boolean isEmail(String data) {
return data.matches("^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}$");
}
private static boolean isPhoneNumber(String data) {
return data.matches("^[0-9().\\-+ ]{10,20}$");
}
private static String maskEmail(String email) {
email = email.toLowerCase();
String[] parts = email.split("@");
String local = parts[0];
String domain = parts[1];
if (local.length() > 2) {
local = local.charAt(0) + "*" + local.charAt(local.length() - 1);
} else {
local = local.charAt(0) + "*";
}
return local + "@" + domain;
}
private static String maskPhoneNumber(String phone) {
phone = phone.replaceAll("[^0-9]", "");
int len = phone.length();
String maskedPhone = "";
if (len == 10) {
maskedPhone = "###-###-" + phone.substring(6);
} else if (len == 11) {
maskedPhone = "+#-###-###-" + phone.substring(7);
} else if (len == 12) {
maskedPhone = "+##-###-###-" + phone.substring(8);
} else if (len == 13) {
maskedPhone = "+###-###-###-" + phone.substring(9);
}
return maskedPhone;
}
Protecting Personal Information โ
def solution(lamps):
from collections import defaultdict
illumination_count = defaultdict(int)
for lamp in lamps:
coord, radius = lamp
for i in range(coord - radius, coord + radius + 1):
illumination_count[i] += 1
unique_illumination_count = sum(1 for count in illumination_count.values() if count == 1)
return unique_illumination_count
from collections import defaultdict
illumination_count = defaultdict(int)
for lamp in lamps:
coord, radius = lamp
for i in range(coord - radius, coord + radius + 1):
illumination_count[i] += 1
unique_illumination_count = sum(1 for count in illumination_count.values() if count == 1)
return unique_illumination_count