Do Comment, uptill where you guys were able to think for this problem & what you guys learned in today's Problem ❤!! Checkout DSA-169 Series: kzbin.info/www/bejne/a3PYfImJYruhrdU Problem Link: leetcode.com/problems/shortest-path-to-get-all-keys/description/ Code & Notes: drive.google.com/file/d/1OxGaZe2jH-lXo1ry7Ay0UN_MIBnrLyvE/view?usp=sharing
@GodOfFaith Жыл бұрын
hey aryan i wanna ask you something thats very off topic , why don't you join google as an SDE ? i mean you can get referrals much easily as you are working in goldman sachs.... your coding skills are so good.... and thats why i was wondering.
@morrisonsempire9354 Жыл бұрын
Can you please explain this doubt in the while loop if i dont use that size loop and direcly doing the increment of steps during popoing the element as i generally do any of bfs kind of questions then it is giving wrong answer in first 2 test case why?? while (!q.empty()) { vector curr = q.front(); q.pop(); ++steps; if (curr[0] == (1 = 0 and newrow < n and newcol >= 0 and newcol < m) { char ch = grid[newrow][newcol]; if (ch == '#') continue; if (ch >= 'a' and ch (ch - 'A') & 1) == 0) continue; if (!visit.count(to_string(keys) + " " + to_string(newrow) + " " + to_string(newcol))) { visit.insert(to_string(keys) + " " + to_string(newrow) + " " + to_string(newcol)); q.push({keys, newrow, newcol}); } } } }
@Yashcolab5 ай бұрын
that 9:21 moment came and i was totally unprepared for it lmao XD
@anexocelisia9377 Жыл бұрын
was waiting
@tejuschaturvedi6234 Жыл бұрын
excellent explanaton for such a tough question .
@SurajYadav-py1do Жыл бұрын
amazing explanation bro
@dewanshpatle9056 Жыл бұрын
man those jokes in middle are really awesome, you are a great explainer. Thanks for all the hardwork ❤.
@aryamanagarwal1977 Жыл бұрын
Sir I saw your baap graph series and legit it was the best graph plyalist I have seen so far , and I was able to solve this question myself Great work sir BTW I am also from mnnit (cse)😅😅😅
@sherlockjunior8612 Жыл бұрын
Why is no one talking about what he says here: 9:18 XD
@beinghappy9223 Жыл бұрын
Toughest question I faced so far Btw amazing explanation .
@ankurchaudhary924 Жыл бұрын
Note::: that the goal is to obtain all the keys not to open all the locks.
@muskankashyap1776 Жыл бұрын
code is failing at test case ["@...a",".###A","b.BCc"]..
@adityaanand7994 ай бұрын
yess it is failing on this
@adityaanand7994 ай бұрын
@ARYANMITTAL
@jagratgupta8392 Жыл бұрын
Very tough ques bhaiya 😅😅...got the intuition but solving and checking each and every thing was really confusing and tough ....you explained really well❤❤
@sahilyadav5662 Жыл бұрын
why you have used the loop for(int i=0;i
@yugaanshgautam6893 Жыл бұрын
to update steps efficiently, you require one step to proceed to the next level in the graph.
@hitengoyal5457 Жыл бұрын
Why can't we apply dijkstra algorithm?
@SachinKumar-cd1sg4 ай бұрын
here the graph is not weighted so need to apply dijkstra
@pool477 Жыл бұрын
Future striver
@animesh414 Жыл бұрын
kya ham dfs se ye problem solve nhi kr skte kya ?
@asthajain2511 Жыл бұрын
Cant we apply dfs here ??
@ARYANMITTAL Жыл бұрын
Nopes, forget keys, locks and obstacles, if i had asked you give me shortest path to reach from x1,y1 to x2, y2. How will you have solved it via DFS? It just traverse the path depth wise, thus only making sure that we reach that point, and not in shortest time/distance.
@anexocelisia9377 Жыл бұрын
@@ARYANMITTAL can we apply bfs everytime we need to find the shortest path?
@raunakkumar6144 Жыл бұрын
@@ARYANMITTALWe can use dfs with backtraking to solve it write ,yeah it will be exponential complexity ,but we can right?
@gyanaranjansahoo6258 Жыл бұрын
if (c >= 'A' && c > (c - 'A')) & 1) == 0) { continue; } in this part can't we do ((1 >> (c - 'A')) & 1) == 0 insted of ((keys >> (c - 'A')) & 1) == 0 ?
@shlokjhunjhunwalakol Жыл бұрын
Can anyone tell me why my code is giving tle 😭😭😭 class Solution { private: bool isValid(vector& grid, int i, int j, int m, int n, vector& keys){ if(i=n || grid[i][j]=='#')return false; if(grid[i][j]>='A' && grid[i][j]
@CristianoRonaldo-ku1uz Жыл бұрын
Can you help me with the code. Getting WA on TC-13 I think I have to do backtracking properly but not getting how to do it. class Solution { public: int dx[4] = {0,0,1,-1}; int dy[4] = {1,-1,0,0}; vector grids; multiset st; void help(vector&vp, multiset stcpy, int &i, int &j, int &ans,int sol,vector vis){ if(vp[i][j]==INT_MAX){ return; } if(vp[i][j]==INT_MIN && stcpy.find(grids[i][j]-'A')==stcpy.end()){ return; } if(stcpy == st){ ans = min(ans,sol); return; } vis[i][j] = 1; for(int l =0; l=0 && sti=0 && stj=0 && vp[sti][stj]
@koushikboddapalli4400 Жыл бұрын
Whats wrong with this code...please figure it out... thanks in advance vector directions = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}}; int shortestPathAllKeys(vector& grid) { int n = grid.size(); int m = grid[0].size(); int x = -1,y = -1,max_len = -1; for(int i = 0;i < n;i++) { for(int j = 0;j < m;j++) { char c = grid[i][j]; if(grid[i][j] == '@') { x = i; y = j; } if(grid[i][j]>='a' && grid[i][j]=0 && nx < n && ny>=0 && ny < m && grid[nx][ny]!='#'); }; int steps = 0; while(!q.empty()) { int size = q.size(); for(int i = 0;i < size;i++) { int keys = q.front().first; int curr = q.front().second; q.pop(); if(keys == (1 = 'a' && c
@parthpandey. Жыл бұрын
Don't take it the wrong way, but your explanations are often too lengthy, which can be boring for us. Additionally, it may seem like you are trying to come across as too smart. To be honest, if I were present there, I might have been tempted to express my frustration with a tight slap. I'm saying this because your video tends to irritate me.
@namanchandak1532 Жыл бұрын
What is the error in my code it is failing the below test case ["...#","a..@","#..#","b.#B",".##A"] class Solution { public: int n,m; int dfs(vector& grid,int i,int j,int lock,set&st,vector&dp) { if(i=m || grid[i][j]=='#') return 1e9; if(lock==0 ) return 0; cout
@shwetanshusood9450 Жыл бұрын
Can you help me with this code.. i am not getting how to do it The general public often body shame the people who are obese or not beautiful as per their standard of weight. They do not even consider that it might be a medical condition for some people. Because of this, the people start doubting themselves and start cutting them off from the general discussions or the public places. To fight body shaming and spread awareness about the issue, an event is conducted in the city where people are participating and are ranked according to their weights from highest to lowest. The people with the same weights are ranked the same. There are N people who have already participated. The official has noted their weight and has ranked them. The problem is, he has fallen sick and there are still P people who are left to rank and participate. Considering this, you are expected to finish the process and provide the rank of the P people. Once the person is ranked, his weight is included in the category and the weight of the new person will have to consider this weight also to be ranked. To help you out, the new P people are organized in a queue in increasing order of their weights. Input Format The first line of input consists of two space-separated integers, N and P, number of people already ranked and number of people left to be ranked respectively. The second line of input consists of N space-separated integers arranged in decreasing order, representing the weight of the N people. The third line of input consists of P space-separated integers arranged in increasing order, representing the weight of the P people. Constraints 1
@shlokjhunjhunwalakol Жыл бұрын
Can anyone tell me why my code is giving tle 😭😭😭 class Solution { private: bool isValid(vector& grid, int i, int j, int m, int n, vector& keys){ if(i=n || grid[i][j]=='#')return false; if(grid[i][j]>='A' && grid[i][j]
@shlokjhunjhunwalakol Жыл бұрын
Can anyone tell me why my code is giving tle 😭😭😭 class Solution { private: bool isValid(vector& grid, int i, int j, int m, int n, vector& keys){ if(i=n || grid[i][j]=='#')return false; if(grid[i][j]>='A' && grid[i][j]
@shlokjhunjhunwalakol Жыл бұрын
Can anyone tell me why my code is giving tle 😭😭😭 class Solution { private: bool isValid(vector& grid, int i, int j, int m, int n, vector& keys){ if(i=n || grid[i][j]=='#')return false; if(grid[i][j]>='A' && grid[i][j]
@shlokjhunjhunwalakol Жыл бұрын
Can anyone tell me why my code is giving tle 😭😭😭 class Solution { private: bool isValid(vector& grid, int i, int j, int m, int n, vector& keys){ if(i=n || grid[i][j]=='#')return false; if(grid[i][j]>='A' && grid[i][j]