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)
Two Operation โ
Python 3
Python 3
๐1
TCS IRA answers...
Java answers
26)7.25
27)3rd option
28)55
29)the output will be 4 3 undefined 1
30)124
31)it will be concatenate both the strings and print as 1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9,10
32)//
33)object
34)<img src="jtp.png">
35)u
36)Grade:C
37)10 11 Aman
38)a=22.5,b=21.0
39)5070
40)2345
41)Learning Java Learning Java
42)6.3
43)6789
41) Learning Java learning Java
42) 6,3
43)6789
44) class MyClass
45)56 1
46) exdends
47) javt
48) public static int cal(a,name)
49) composition
50) math()
Java answers
26)7.25
27)3rd option
28)55
29)the output will be 4 3 undefined 1
30)124
31)it will be concatenate both the strings and print as 1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9,10
32)//
33)object
34)<img src="jtp.png">
35)u
36)Grade:C
37)10 11 Aman
38)a=22.5,b=21.0
39)5070
40)2345
41)Learning Java Learning Java
42)6.3
43)6789
41) Learning Java learning Java
42) 6,3
43)6789
44) class MyClass
45)56 1
46) exdends
47) javt
48) public static int cal(a,name)
49) composition
50) math()
๐2
TCS IRA JAVA ANSWERS
1)Robotic
2)true
3)native application
4)big data
1)Robotic
2)true
3)native application
4)big data
๐โ ๏ธโJobs Updatesโโ ๏ธ๐
ColorTokens - https://t.me/fresherearth/2534
Infosys Off Campus - https://t.me/fresherearth/2535
TCS - https://t.me/fresherearth/2530
โ Share with your friends
Telegram - t.me/superexams
ColorTokens - https://t.me/fresherearth/2534
Infosys Off Campus - https://t.me/fresherearth/2535
TCS - https://t.me/fresherearth/2530
โ Share with your friends
Telegram - t.me/superexams