Series Problem
Java โ (Tech Mahindra)
Java โ (Tech Mahindra)
โ ๏ธ Reminder - who didn't apply yet
IBM - t.me/fresherearth/2492
Replicon - t.me/fresherearth/2494
Infosys - t.me/fresherearth/2496
Hexaware - t.me/fresherearth/2498
ColorTokens - t.me/fresherearth/2500
Reliance Industries - t.me/fresherearth/2502
GlobalLogic - t.me/fresherearth/2504
AstraZeneca - t.me/fresherearth/2507
โ Share in ur College WhatsApp Groups
๐Direct & 100% Ads Free Links
Telegram - t.me/fresherearth
IBM - t.me/fresherearth/2492
Replicon - t.me/fresherearth/2494
Infosys - t.me/fresherearth/2496
Hexaware - t.me/fresherearth/2498
ColorTokens - t.me/fresherearth/2500
Reliance Industries - t.me/fresherearth/2502
GlobalLogic - t.me/fresherearth/2504
AstraZeneca - t.me/fresherearth/2507
โ Share in ur College WhatsApp Groups
๐Direct & 100% Ads Free Links
Telegram - t.me/fresherearth
โ
โ
โ
#HackerRank Department Summary - SQL HackerRank Solution
select d.name, count(unique(e.id)) as c
from department d, employee e
where d.id = e.dept_id
group by d.name
order by c desc, d.name;
select d.name, 0
from department d
left outer join employee e on d.id = e.dept_id
where e.id is null
group by d.name
order by d.name;
โ
Share in ur College WhatsApp GroupsInfosys 3pm slot answers
Q1) if a means
23
Q2)C
111
Q3)76
B
Q1) if a means
23
Q2)C
111
Q3)76
B
Q4) which two signs
D
++
D
++
๐1
type below write ur code in java
type below write ur code in java
#include<bits/stdc++.h>
using namespace std;
vector<pair<int,int>>adj[1000001];
int main(){
int n;
cin>>n;
unordered_map<int,int>mp;
for(int i=0;i<n;++i){
int x;
cin>>x;
mp[x]=INT_MAX;
}
int e;
cin>>e;
for(int i=0;i<e;++i){
int x,y,d;
cin>>x>>y>>d;
adj[x].push_back({y,d});
}
int src,dest;
cin>>src>>dest;
set<pair<int,int>>s;
mp[src]=0;
s.insert({0,src});
while(!s.empty()){
pair<int,int>tmp=*(s.begin());
s.erase(s.begin());
int u=tmp.second;
for(auto i=adj[u].begin();i!=adj[u].end();++i){
int v=(*i).first;
int weight=(*i).second;
if(mp[v]>mp[u]+weight){
if(mp[v]!=INT_MAX)
s.erase(s.find({mp[v],v}));
mp[v]=mp[u]+weight;
s.insert({mp[v],v});
}
}
}
if(mp[dest]==INT_MAX)
cout<<"-1"<<endl;
else
cout<<mp[dest]<<endl;
return 0;
}
Juspay (C++)โ
using namespace std;
vector<pair<int,int>>adj[1000001];
int main(){
int n;
cin>>n;
unordered_map<int,int>mp;
for(int i=0;i<n;++i){
int x;
cin>>x;
mp[x]=INT_MAX;
}
int e;
cin>>e;
for(int i=0;i<e;++i){
int x,y,d;
cin>>x>>y>>d;
adj[x].push_back({y,d});
}
int src,dest;
cin>>src>>dest;
set<pair<int,int>>s;
mp[src]=0;
s.insert({0,src});
while(!s.empty()){
pair<int,int>tmp=*(s.begin());
s.erase(s.begin());
int u=tmp.second;
for(auto i=adj[u].begin();i!=adj[u].end();++i){
int v=(*i).first;
int weight=(*i).second;
if(mp[v]>mp[u]+weight){
if(mp[v]!=INT_MAX)
s.erase(s.find({mp[v],v}));
mp[v]=mp[u]+weight;
s.insert({mp[v],v});
}
}
}
if(mp[dest]==INT_MAX)
cout<<"-1"<<endl;
else
cout<<mp[dest]<<endl;
return 0;
}
Juspay (C++)โ
#include<bits/stdc++.h>
using namespace std;
vector<int>adj[1000001];
void solve(int src,int dest,unordered_map<int,int>&mp){
mp[src]=1;
for(int i=0;i<adj[src].size();++i){
if(!mp[adj[src][i]]){
solve(adj[src][i],dest,mp);
}
}
}
int main(){
int n;
cin>>n;
unordered_map<int,int>mp;
for(int i=0;i<n;++i){
int x;
cin>>x;
mp[x]=0;
}
int e;
cin>>e;
for(int i=0;i<e;++i){
int x,y;
cin>>x>>y;
adj[x].push_back(y);
}
int src,dest;
cin>>src>>dest;
solve(src,dest,mp);
cout<<mp[dest]<<endl;
return 0;
}
Juspay (C++)โ
using namespace std;
vector<int>adj[1000001];
void solve(int src,int dest,unordered_map<int,int>&mp){
mp[src]=1;
for(int i=0;i<adj[src].size();++i){
if(!mp[adj[src][i]]){
solve(adj[src][i],dest,mp);
}
}
}
int main(){
int n;
cin>>n;
unordered_map<int,int>mp;
for(int i=0;i<n;++i){
int x;
cin>>x;
mp[x]=0;
}
int e;
cin>>e;
for(int i=0;i<e;++i){
int x,y;
cin>>x>>y;
adj[x].push_back(y);
}
int src,dest;
cin>>src>>dest;
solve(src,dest,mp);
cout<<mp[dest]<<endl;
return 0;
}
Juspay (C++)โ
๐1
Nick's check code โ
(Python 3)
(Python 3)