int l=0,r=1e14;
while(l<r){
int mid=(l+r+1)>>1;
int ans=1;
int pr=0;
for(int i=0;i<n;i++){
if(pr>starts[i]+d){
ans=0;
}else{
pr=max(pr+mid,starts[i]);
}
}
if(ans){
l=mid;
}else{
r=mid-1;
}
}
return l;
Range selection deshaw
2/15
☃4❤1👍1
long getMaxDist(std::vector<long> starts, long d) {
int n = starts.size();
sort(starts.begin(), starts.end()); // Sort the starting points in ascending order
long l = 0, r = 1e14;
while (l < r) {
long mid = (l + r + 1) / 2;
int ans = 1;
long pr = 0;
for (int i = 0; i < n; i++) {
if (pr > starts[i] + d) {
ans = 0;
} else {
pr = std::max(pr + mid, starts[i]);
}
}
if (ans) {
l = mid;
} else {
r = mid - 1;
}
}
return l;
}c++ Deshaw range queries
☃7👍4❤🔥1
Do you guys want us to post internship and placement opportunities too in this grp?
Anonymous Poll
88%
Yes
12%
No
❤9👍5☃2❤🔥1
tomorrow which oa now comment in this thread?
✍10❤1👍1
Product Internship at Directi
Link
https://jobs.lever.co/directi/cf481540-aa1b-46b0-bb73-96d0b8100a2d
Try to take referral (good cp profile have high chance in this)
Link
https://jobs.lever.co/directi/cf481540-aa1b-46b0-bb73-96d0b8100a2d
Try to take referral (good cp profile have high chance in this)
👍15❤3
Company Name : Beepkart
Role : Software Engineer Internship
Batch : 2023,2024,2022 passouts
Duration : 6-9 months
Link : https://docs.google.com/forms/d/e/1FAIpQLScbkovP5Ef_sALJDgD4X81nvQ68ty8af729OyZq0NaxeLS-gg/viewform
Role : Software Engineer Internship
Batch : 2023,2024,2022 passouts
Duration : 6-9 months
Link : https://docs.google.com/forms/d/e/1FAIpQLScbkovP5Ef_sALJDgD4X81nvQ68ty8af729OyZq0NaxeLS-gg/viewform
👍11❤3☃2
Messages in this channel will be automatically deleted after 1 month