#include<bits/stdc++.h>
using namespace std;
const int N=6e6+10000;
int ch[N][2];
int sz[N];
int a[N];
int n,idx;
void insert(int x)
{
int p=0;
for(int i=29;i>=0;i--)
{
int u=(x>>i)&1;
if(!ch[p][u]) ch[p][u]=++idx;
p=ch[p][u];
++sz[p];
}
}
int dfs(int u)
{
int l=ch[u][0],r=ch[u][1];
if(l && r) return min(sz[l]-1+dfs(r),sz[r]-1+dfs(l));
if(l) return dfs(l);
if(r) return dfs(r);
}
int main()
{
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
scanf("%d",&a[i]);
insert(a[i]);
}
printf("%d\n",dfs(0));
}
uber โ
using namespace std;
const int N=6e6+10000;
int ch[N][2];
int sz[N];
int a[N];
int n,idx;
void insert(int x)
{
int p=0;
for(int i=29;i>=0;i--)
{
int u=(x>>i)&1;
if(!ch[p][u]) ch[p][u]=++idx;
p=ch[p][u];
++sz[p];
}
}
int dfs(int u)
{
int l=ch[u][0],r=ch[u][1];
if(l && r) return min(sz[l]-1+dfs(r),sz[r]-1+dfs(l));
if(l) return dfs(l);
if(r) return dfs(r);
}
int main()
{
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
scanf("%d",&a[i]);
insert(a[i]);
}
printf("%d\n",dfs(0));
}
uber โ
for ca in range(int(input())):
f=True
s=input()
t=input()
a=''
for i in range(20):
a+=s
if len(a)%len(t)==0 and a==t*(len(a)//len(t)):
print(a)
f=False
break
if f:
print('NO')
Swaraj
Uber โ
f=True
s=input()
t=input()
a=''
for i in range(20):
a+=s
if len(a)%len(t)==0 and a==t*(len(a)//len(t)):
print(a)
f=False
break
if f:
print('NO')
Swaraj
Uber โ
int minimumRemovals(vector<int>& arr) {
int n = arr.size();
int maxElement = *max_element(arr.begin(), arr.end());
int minElement = *min_element(arr.begin(), arr.end());
int maxIndex = find(arr.begin(), arr.end(), maxElement) - arr.begin();
int minIndex = find(arr.begin(), arr.end(), minElement) - arr.begin();
if (maxIndex > minIndex) swap(maxIndex, minIndex);
int removalsFromLeft = minIndex + 1;
int removalsFromRight = n - maxIndex;
int removalsBothEnds = maxIndex + 1 + (n - minIndex);
return min({removalsFromLeft, removalsFromRight, removalsBothEnds});
}
Minimum Removals โ
int n = arr.size();
int maxElement = *max_element(arr.begin(), arr.end());
int minElement = *min_element(arr.begin(), arr.end());
int maxIndex = find(arr.begin(), arr.end(), maxElement) - arr.begin();
int minIndex = find(arr.begin(), arr.end(), minElement) - arr.begin();
if (maxIndex > minIndex) swap(maxIndex, minIndex);
int removalsFromLeft = minIndex + 1;
int removalsFromRight = n - maxIndex;
int removalsBothEnds = maxIndex + 1 + (n - minIndex);
return min({removalsFromLeft, removalsFromRight, removalsBothEnds});
}
Minimum Removals โ
int solve(vector<int>& nums)
{
int N = nums.size();
int idx1 = min_element(nums.begin(), nums.end()) - nums.begin();
int idx2 = max_element(nums.begin(), nums.end()) - nums.begin();
int L = min(idx1, idx2);
int R = max(idx1, idx2);
int left = R + L;
int right = N - L;
int both = L + 1 + N - R;
int ans = min({left, right, both});
return ans;
}
{
int N = nums.size();
int idx1 = min_element(nums.begin(), nums.end()) - nums.begin();
int idx2 = max_element(nums.begin(), nums.end()) - nums.begin();
int L = min(idx1, idx2);
int R = max(idx1, idx2);
int left = R + L;
int right = N - L;
int both = L + 1 + N - R;
int ans = min({left, right, both});
return ans;
}
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Company Name: Salesforce
๐ Job Title: Software Engineering AMTS
โ๐ป YOE: 2024 grads only
โก๏ธ Apply: https://careers.salesforce.com/en/jobs/jr261253/software-engineering-amts/
Please do share in your college grps and in case you are applying please react on this post:) ๐โค๏ธ
๐ Job Title: Software Engineering AMTS
โ๐ป YOE: 2024 grads only
โก๏ธ Apply: https://careers.salesforce.com/en/jobs/jr261253/software-engineering-amts/
Please do share in your college grps and in case you are applying please react on this post:) ๐โค๏ธ
๐1
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
#include <bits/stdc++.h>
#define ll long long
using namespace std;
string solve(string&a,string&b)
{
ll n=a.length();
ll m=b.length();
unordered_map<char,ll> m1,m2;
for(char it:a) m1[it]++;
for(char it:b) m2[it]++;
string mid="",ans="";
for (char i='a';i<='z';i++)
{
if(m1[i]%2 and m2[i]%2 and mid.length()<=1) mid=string(2,i);
if((m1[i]%2 or m2[i]%2) and mid.length()==0) mid=i;
ans+=string((m1[i]/2+m2[i]/2),i);
}
string tt=ans;
if (mid.length()==2)
{
tt+=mid[0];
ans+=mid[0];
sort(begin(ans),end(ans));
tt=ans+string(rbegin(ans),rend(ans));
}
else tt+=mid+string(rbegin(ans),rend(ans));
return tt;
}
signed main()
{
string s,t; cin>>s>>t;
cout<<solve(s,t);
return 0;
}
#define ll long long
using namespace std;
string solve(string&a,string&b)
{
ll n=a.length();
ll m=b.length();
unordered_map<char,ll> m1,m2;
for(char it:a) m1[it]++;
for(char it:b) m2[it]++;
string mid="",ans="";
for (char i='a';i<='z';i++)
{
if(m1[i]%2 and m2[i]%2 and mid.length()<=1) mid=string(2,i);
if((m1[i]%2 or m2[i]%2) and mid.length()==0) mid=i;
ans+=string((m1[i]/2+m2[i]/2),i);
}
string tt=ans;
if (mid.length()==2)
{
tt+=mid[0];
ans+=mid[0];
sort(begin(ans),end(ans));
tt=ans+string(rbegin(ans),rend(ans));
}
else tt+=mid+string(rbegin(ans),rend(ans));
return tt;
}
signed main()
{
string s,t; cin>>s>>t;
cout<<solve(s,t);
return 0;
}
Company โ CodeInterns
Role โ Data Science Intern
Exp. โ Fresher
Apply Here โ https://internshala.com/internship/detail/work-from-home-part-time-data-science-internship-at-codeinterns1721021097?utm_source=cp_link&referral=web_share
Company โ Ozibook Tech Solutions Private Limited
Role โ Business Analytics Intern
Exp. โ Fresher
Apply Here โ https://internshala.com/internship/detail/work-from-home-part-time-business-analytics-internship-at-ozibook-tech-solutions-private-limited1720800501?utm_source=cp_link&referral=web_share
Company โ Vodafone
Role โ Data Analyst
Exp. โ 0-2 yrs
Apply Here โ https://www.foundit.in/job/data-analyst-vodafone-pune-31193135?searchId=7136e162-6fd1-41b3-af85-aa0fc6b1c14a
Company โ Ignitefortune Tech
Role โ Data Science Associate
Exp. โ 0-1 yr
Apply Here โ https://www.naukri.com/job-listings-data-science-associate-ignitefortune-tech-pune-0-to-1-years-140724001970?src=jobsearchDesk&sid=17210278691665089_3&xp=10&px=1&nignbevent_src=jobsearchDeskGNB
Company โ The Golden Rise
Role โ Business Intelligence Analyst
Exp. โ Fresher
Apply Here โ https://www.linkedin.com/jobs/view/3976531202
Company โ Blockchain for the Next Billion
Role โ Data Analyst
Exp. โ 0-5 yrs
Apply Here โ https://www.linkedin.com/jobs/view/3972831179
Company โ ServiceNow
Role โData Scientist (SQL & Python)
Exp. โ Fresher
Apply Here โ https://www.linkedin.com/jobs/view/3976572885
Role โ Data Science Intern
Exp. โ Fresher
Apply Here โ https://internshala.com/internship/detail/work-from-home-part-time-data-science-internship-at-codeinterns1721021097?utm_source=cp_link&referral=web_share
Company โ Ozibook Tech Solutions Private Limited
Role โ Business Analytics Intern
Exp. โ Fresher
Apply Here โ https://internshala.com/internship/detail/work-from-home-part-time-business-analytics-internship-at-ozibook-tech-solutions-private-limited1720800501?utm_source=cp_link&referral=web_share
Company โ Vodafone
Role โ Data Analyst
Exp. โ 0-2 yrs
Apply Here โ https://www.foundit.in/job/data-analyst-vodafone-pune-31193135?searchId=7136e162-6fd1-41b3-af85-aa0fc6b1c14a
Company โ Ignitefortune Tech
Role โ Data Science Associate
Exp. โ 0-1 yr
Apply Here โ https://www.naukri.com/job-listings-data-science-associate-ignitefortune-tech-pune-0-to-1-years-140724001970?src=jobsearchDesk&sid=17210278691665089_3&xp=10&px=1&nignbevent_src=jobsearchDeskGNB
Company โ The Golden Rise
Role โ Business Intelligence Analyst
Exp. โ Fresher
Apply Here โ https://www.linkedin.com/jobs/view/3976531202
Company โ Blockchain for the Next Billion
Role โ Data Analyst
Exp. โ 0-5 yrs
Apply Here โ https://www.linkedin.com/jobs/view/3972831179
Company โ ServiceNow
Role โData Scientist (SQL & Python)
Exp. โ Fresher
Apply Here โ https://www.linkedin.com/jobs/view/3976572885
Internshala
Data Science Work From Home Part Time Internship at CodeInterns
Join our team at CodeInterns as a data science intern and dive into the exciting world of data analysis and machine learning! As a member of our dynamic team, you will have the opportunity to work on cutting-edge projects and gain hands-on experience in theโฆ
๐2๐1
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
class Solution {
public:
vector<int> countServers(int N, vector<vector<int>>& L, int x, vector<int>& Q) {
vector<int> idx, res(Q.size(), 0);
for(int i = 0; i < Q.size(); i++) idx.push_back(i);
sort(begin(idx), end(idx), [&](auto a, auto b) {return Q[a] < Q[b];});
sort(begin(L), end(L), [](auto &a, auto &b) {return a[1] < b[1];});
int p0 = 0, p1 = 0, cnt = 0;
unordered_map<int, int> mp;
for(int i = 0; i < idx.size(); i++) {
while(p1 < L.size() && L[p1][1] <= Q[idx[i]]) if(++mp[L[p1++][0]] == 1) cnt++;
while(p0 < L.size() && L[p0][1] < Q[idx[i]]-x) if(--mp[L[p0++][0]] == 0) cnt--;
res[idx[i]] = N - cnt;
}
return res;
}
};
Meesho โ
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
int mincost(vector<int> &pods,vector<int> &cost){
map<int,multiset<int>> mp;
for(int i=0;i<pods.size();i++){
mp[pods[i]].insert(cost[i]);
}
int ans = 0;
int curr = (*mp.begin()).first,sm = 0;
multiset<int> se;
while(1){
if(se.size()==0){
if(mp.lower_bound(curr) == mp.end()) break;
curr = (*mp.lower_bound(curr)).first;
}
if(mp.find(curr) != mp.end())
for(auto &x:mp[curr]){
se.insert(x);
sm += x;
}
auto it = se.end();
it--;
sm -= *it;
ans += sm;
se.erase(it);
curr++;
}
return ans;
}
Meesho โ
map<int,multiset<int>> mp;
for(int i=0;i<pods.size();i++){
mp[pods[i]].insert(cost[i]);
}
int ans = 0;
int curr = (*mp.begin()).first,sm = 0;
multiset<int> se;
while(1){
if(se.size()==0){
if(mp.lower_bound(curr) == mp.end()) break;
curr = (*mp.lower_bound(curr)).first;
}
if(mp.find(curr) != mp.end())
for(auto &x:mp[curr]){
se.insert(x);
sm += x;
}
auto it = se.end();
it--;
sm -= *it;
ans += sm;
se.erase(it);
curr++;
}
return ans;
}
Meesho โ
def is_possible(network_nodes, network_from, network_to):
from collections import defaultdict
tree = defaultdict(list)
for i in range(len(network_from)):
tree[network_from[i]].append(network_to[i])
tree[network_to[i]].append(network_from[i])
result = ['0'] * (network_nodes + 1)
def dfs(node, parent):
paired = False
for child in tree[node]:
if child != parent:
if not dfs(child, node):
if paired:
return False
paired = True
if paired:
result[node] = '1'
return True
return False
dfs(1, -1)
return ''.join(result[1:])
network_nodes = 4
network_from = [3,2,1]
network_to = [4,4,2]
print(is_possible(network_nodes, network_from, network_to))
//messho 3
from collections import defaultdict
tree = defaultdict(list)
for i in range(len(network_from)):
tree[network_from[i]].append(network_to[i])
tree[network_to[i]].append(network_from[i])
result = ['0'] * (network_nodes + 1)
def dfs(node, parent):
paired = False
for child in tree[node]:
if child != parent:
if not dfs(child, node):
if paired:
return False
paired = True
if paired:
result[node] = '1'
return True
return False
dfs(1, -1)
return ''.join(result[1:])
network_nodes = 4
network_from = [3,2,1]
network_to = [4,4,2]
print(is_possible(network_nodes, network_from, network_to))
//messho 3
int mincost(vector<int> &pods,vector<int> &cost){
map<int,multiset<int>> mp;
for(int i=0;i<pods.size();i++){
mp[pods[i]].insert(cost[i]);
}
int ans = 0;
int curr = (*mp.begin()).first,sm = 0;
multiset<int> se;
while(1){
if(se.size()==0){
if(mp.lower_bound(curr) == mp.end()) break;
curr = (*mp.lower_bound(curr)).first;
}
if(mp.find(curr) != mp.end())
for(auto &x:mp[curr]){
se.insert(x);
sm += x;
}
auto it = se.end();
it--;
sm -= *it;
ans += sm;
se.erase(it);
curr++;
}
return ans;
}
// Meesho 2
map<int,multiset<int>> mp;
for(int i=0;i<pods.size();i++){
mp[pods[i]].insert(cost[i]);
}
int ans = 0;
int curr = (*mp.begin()).first,sm = 0;
multiset<int> se;
while(1){
if(se.size()==0){
if(mp.lower_bound(curr) == mp.end()) break;
curr = (*mp.lower_bound(curr)).first;
}
if(mp.find(curr) != mp.end())
for(auto &x:mp[curr]){
se.insert(x);
sm += x;
}
auto it = se.end();
it--;
sm -= *it;
ans += sm;
se.erase(it);
curr++;
}
return ans;
}
// Meesho 2