@@codestorywithMIK thanks bhaiya.... You have played an important role in my life for getting this opportunity. The OA round which was based on DSA was a cakewalk for me. 🥰🥹
so glad to know. Please always keep following points in your mind - 1) Keep working hard, never settle. 2) Enjoy as well in life 3) Work hard to fulfill your dreams + your PARETN’S dreams All the best
Dijkstra's Based Problems - github.com/MAZHARMIK/Interview_DS_Algo/tree/master/Graph/Dijkstra'a%20Based%20Problems Dijkstra's Videos in my Graph Concepts & Qns Playlist - th-cam.com/video/xQ3vjWwFRuI/w-d-xo.html Thank you to all of you for your kind reviews and comments❣
Hi bro, Your videos are very helpful and love the way you make this easier to understand. Just one suggestion it would be great if at the end of the video you show dry run of Java program
For the same code in kotlin it is throwing Time Limit exceeded. it was failing for N size of 1000. Maybe they have added new test case now. Will have to cache the results
Java code for this ques- class Pair{ int node; double prob; Pair(int node,double prob){ this.node=node; this.prob=prob; } } class Solution { public double maxProbability(int n, int[][] edges, double[] succProb, int start, int end) { List adj=new ArrayList(); for(int i=0;i Double.compare(b.prob,a.prob)); q.offer(new Pair(start,1.0));
a slight overlook, since this is an undirected graph we also need to store the probability of going from v to u and not just u to v so we need to add both of these while creating the adjacency map adj[u].push_back({v, prob}); adj[v].push_back({u, prob});
@level_up.1908 As of now, I only record simply and upload it. Soon i will buy some equipments for good editing and quality. Hope to help you all in better way
here is the code class Solution { public: double dfs(vector& list, int sv, int end, vector& visited){ if(sv == end){ return 1; } visited[sv] = true; double answer = 0; for(int i=0; i
@@mileshsoni5016 COZ IT WILL GIVE TLE class Solution { public: void dfs(unordered_map& adj, vector& visited, double& maxi, double ans, int u, int c) { if(u == c) { maxi = max(maxi, ans); return; } visited[u] = true; for(auto& x : adj[u]) { int k = x.first; double l = x.second; if(!visited[k]) { dfs(adj, visited, maxi, ans * l, k, c); } } visited[u] = false; // backtrack to allow other paths } double maxProbability(int n, vector& a, vector& p, int s, int e) { unordered_map adj; for(int i = 0; i < a.size(); i++) { int u = a[i][0]; int v = a[i][1]; double d = p[i]; adj[u].push_back({v, d}); adj[v].push_back({u, d}); } vector visited(n, false); double maxi = 0.0; double ans = 1.0; dfs(adj, visited, maxi, ans, s, e); return maxi; } }; SEE IT GAVE TLE
I went to the Graph concepts playlist and revised Dijkstra from there, believe me I didn't had to watch this video to solve this problem. 😇🥰
You just made my day Tauquir ❤️❤️❤️
And Congratulations on your new internship offer ❤️❤️❤️
Keep growing. We have to achieve more and more and more
@@codestorywithMIK thanks bhaiya.... You have played an important role in my life for getting this opportunity. The OA round which was based on DSA was a cakewalk for me. 🥰🥹
so glad to know.
Please always keep following points in your mind -
1) Keep working hard, never settle.
2) Enjoy as well in life
3) Work hard to fulfill your dreams + your PARETN’S dreams
All the best
@@codestorywithMIK ❣️
same bro
No can teach Graph like you on internet.
I will repeat, you are the "KING OF GRAPHS"
Dijkstra's Based Problems -
github.com/MAZHARMIK/Interview_DS_Algo/tree/master/Graph/Dijkstra'a%20Based%20Problems
Dijkstra's Videos in my Graph Concepts & Qns Playlist - th-cam.com/video/xQ3vjWwFRuI/w-d-xo.html
Thank you to all of you for your kind reviews and comments❣
You have insane level of clarity on how to teach ❤❤❤
i had already seen dijkstra video so i was on the right the track but i was using min heap 😅 thanks for the explanation.
❤️❤️
Literally no one teaches like you bro, thanks for the amazing explanation
❤️❤️
Love your explanation. Graph ko halwa bana diya hai aapne.
Congratulations in advance for 63K . Soon 100k 😎
Awesome video on variant on Dijkstra's algorithm. Thansk Mik for your dedication towards teaching.
Literally no one teaches like you bro
Someone trade said - GOAT of DSA
King of Graphs ❤
NICE SUPER EXCELLENT MOTIVATED
Hi bro,
Your videos are very helpful and love the way you make this easier to understand. Just one suggestion it would be great if at the end of the video you show dry run of Java program
Easy and Best Explaination As Always
Thank you ❤️
great explanation bhaiya .
Thanks a lot bhaiya ❤❤
i will start from scract someday and do this using bellman ford also
Amazing explanation👍
u made it a cakewalk!
thanks❤
Means a lot ❤️❤️
very good explanation
For the same code in kotlin it is throwing Time Limit exceeded. it was failing for N size of 1000. Maybe they have added new test case now. Will have to cache the results
watched only 6 min of video and solved it
Java code for this ques-
class Pair{
int node;
double prob;
Pair(int node,double prob){
this.node=node;
this.prob=prob;
}
}
class Solution {
public double maxProbability(int n, int[][] edges, double[] succProb, int start, int end) {
List adj=new ArrayList();
for(int i=0;i Double.compare(b.prob,a.prob));
q.offer(new Pair(start,1.0));
while(!q.isEmpty()){
Pair temp=q.poll();
int u=temp.node;
double upb=temp.prob;
if(u==end) return upb;
for(Pair it:adj.get(u)){
int v=it.node;
double vpb=it.prob;
if(upb*vpb>prob[v]){
prob[v]=upb*vpb;
q.offer(new Pair(v,prob[v]));
}
}
}
return 0.0;
}
}
Thanks a lot ❤️
Thanks a lot
@@codestorywithMIK ❤❤
thank you
a slight overlook, since this is an undirected graph we also need to store the probability of going from v to u and not just u to v so we need to add both of these while creating the adjacency map
adj[u].push_back({v, prob});
adj[v].push_back({u, prob});
Yuppp...thanks a lot
bhai good explain ,i want to also make such videos with clarity ,can i get a chance to learn from u ,how u do that
Thank you😊
For making the video, I don’t have any fancy equipment. I just do screen recording of my ipad and write on it.
@@codestorywithMIK bhai aap editing nahi krte kya ,kyuki aese toh sahi se video nahi aati 🥲
woh janna hn kese krte hon
@level_up.1908 As of now, I only record simply and upload it.
Soon i will buy some equipments for good editing and quality.
Hope to help you all in better way
Awesome ❤
Please post today's POTD - 864. Shortest Path to Get All Keys
Why using Queue results in lesser runtime when compared to maxheap?
to maintain maxheap it takes logn time.
those who know dijkstra its easy for them
Indeed
Gives your codeforces and leetcode profile link
kyu bro ?
bhai why can't we use dfs?
here is the code
class Solution {
public:
double dfs(vector& list, int sv, int end, vector& visited){
if(sv == end){
return 1;
}
visited[sv] = true;
double answer = 0;
for(int i=0; i
@@mileshsoni5016 COZ IT WILL GIVE TLE
class Solution {
public:
void dfs(unordered_map& adj, vector& visited, double& maxi, double ans, int u, int c) {
if(u == c) {
maxi = max(maxi, ans);
return;
}
visited[u] = true;
for(auto& x : adj[u]) {
int k = x.first;
double l = x.second;
if(!visited[k]) {
dfs(adj, visited, maxi, ans * l, k, c);
}
}
visited[u] = false; // backtrack to allow other paths
}
double maxProbability(int n, vector& a, vector& p, int s, int e) {
unordered_map adj;
for(int i = 0; i < a.size(); i++) {
int u = a[i][0];
int v = a[i][1];
double d = p[i];
adj[u].push_back({v, d});
adj[v].push_back({u, d});
}
vector visited(n, false);
double maxi = 0.0;
double ans = 1.0;
dfs(adj, visited, maxi, ans, s, e);
return maxi;
}
};
SEE IT GAVE TLE
❤
no using PriorityQueue Solution.
public double maxProbability(int n,int[][]edges,double[]succProb,int star,int end){
double[]maxProb=new double[n];
maxProb[start]=1.0;
for(int i=0;imaxProb[src]){
maxProb[src]=maxProb[des]*prob;
flag=true;
}
}
if(flag==false) break;
}
return maxProb[end];
}
🎉❤
Thank you