how do you know when to apply graph algorithms like dijistra,bfs,dfs, rather than dp? I have seen problems like this solved with dp
@codingmohan Жыл бұрын
As mentioned in the video, you'll apply DP when there is no loop in the transition path (usually when you're allowed to go "right & down" i.e. you can never come back to original point).
@dawodujohnson Жыл бұрын
@@codingmohan nice! I get it now
@josephaj8310 Жыл бұрын
Bro could you post the solution for last problem in geeksforgeeks weekly contest 91.
@SDE-wq4tl Жыл бұрын
I got AC using set but TLE using heap, can you please explain why?
@phoenix_1_3 Жыл бұрын
Yh i too got the same error. I guess it's because in heap, we'll have duplicate cells with different elapsing time. We will take the minimum time from them even though we process (pop & check) all duplicate cells. In set, we won't have duplicate cells. While inserting if the minimum time cell will replace the other cell. So no need of processing them again
@lofibeats2344 Жыл бұрын
In 2nd problem today's leetcode cotest why we are reducing numeric value of the range[0, i] to it's remainder with m?
@codingmohan Жыл бұрын
Because we can't generate the entire number in the range [0, i] (the largest number you can have with a 64 bit integer is 2^64 - 1). So, if we try to get the actual number, it will overflow and to just determine the divisibility, we really don't need the original number. Therefore, we've taken the modulus. Hope it helps :)
@lofibeats2344 Жыл бұрын
@@codingmohan yeah how was today's contest though?
@codingmohan Жыл бұрын
@@lofibeats2344 Was good. Last problem was interesting.
@lofibeats2344 Жыл бұрын
@@codingmohan I wanted to say one thing. The way you teach is great but once try to make a video in hindi. Just see once I think your explanation will be more engaging.
@rahulkumarbarik758411 ай бұрын
Anyone Wandering the java code for this amazing explanation !!, Check out this java Code for the above logic //Java Code Starts class Node{ int x; int y; int distance; public Node(int x,int y,int distance){ this.x = x; this.y = y; this.distance = distance; } } class CustomComparator implements Comparator{ @Override public int compare(Node node1,Node node2){ return Integer.compare(node1.distance,node2.distance); } } class Solution { Integer n; Integer m; public boolean isValidate(int x,int y){ if( (x>=0 && x=0 && y1 && grid[1][0]>1) return -1; int[][] time = new int[n][m]; for(int i=0;i newTime){ time[xNew][yNew] = newTime; pq.add(new Node(xNew,yNew,newTime)); } } } } return time[n-1][m-1]; } } //Java Code ends 🙂