Interesting things I learned while solving this question, (for those who are facing TLE while submitting) 1. Never mess with indexes ! If its 1 based index, do not forget to do -1. Also while marking flooded cells KEEP IN MIND that "i" should be Less than EQUAL to mid inside canCross() ! 2. Always keep in mind to use the iterator with "&" while using the for loop. I was using kind of - for(auto dir: directions){..... }. which gave me lot of trouble. Before figuring this out I had 5 unsuccessful submits. for(auto &dir: directions){..... } one solved the TLE issue. Great playlist! Keep it up man! Thanks for good and easy explanation.
Noted Tarun. Feedback taken. Will definitely spend more time on TC and SC. Actually i have been travelling this weekend and got to make this video somehow 😅 Thanks a lot ❤️. I am gonna note this for sure
@@codestorywithMIK Np bro..we understand maintaining this kind of consistency is really tough, along with our day-to-day duties. I really appreciate your efforts
Sir please can you solve this question using disjoint set... much in need. Jo topic or kisi video se smj nhi ata bho apki vedio se ek baar me aa ja tha hai... I try to search the explananion....but or kisi ne nhi banaya... sir please share the same question approch using disjoint set... Ps: Apki video se hi smj att hai concept.
Actually i am already planning to make DSU video for this qn as well. Give me some time as I am travelling hometown this week. Coming next week for sure
Sir I have been trying brute force approach since last few hours, but the output is always resulting in 0. Can you please detect where am I going wrong? class Solution { public: int lastDay = 0; vector dir = {0, -1, 0, 1, 0}; bool dfs(int r, int c, int row, int col, vector& grid, vector& vis) { if (r == row - 1 && c < col && grid[r][c] == 0) return true; if (r >= row || c >= col || r < 0 || c < 0 || vis[r][c] || grid[r][c] == 1) return false; vis[r][c] = 1; for (int i = 0; i < 4; ++i) { int dx = r + dir[i]; int dy = c + dir[i + 1]; if (dfs(dx, dy, row, col, grid, vis)) return true; } return false; } int latestDayToCross(int row, int col, vector& cells) { int n = cells.size(); vector grid(row, vector(col, 0)); vector vis(row, vector(col, 0)); for (int i = 0; i < n; ++i) { vector cellToWater = cells[i]; grid[cellToWater[0]-1][cellToWater[1]-1] = 1; for (int j = 0; j < col; ++j) { for (int ji = 0; ji< row; ++ji) { for (int k = 0; k < col; ++k) { vis[ji][k] = 0; } } if (grid[0][j] == 0 && dfs(0, j, row, col, grid, vis) && !vis[0][j]) { lastDay++; break; } } } return lastDay; } };
Brute Force Code ``` class Solution { public: int x[4]={1,-1,0,0}; int y[4]={0,0,1,-1}; bool canReach(int row,int col,int &m,int &n,vector &mat){ if(row
I'm stopping here and shifting to Striver's channel. Your playlist misses a lot of important questions like Allocate Books, Painter's Partition, and Ship Packages. The questions seem to be randomly picked without any relation to the previous ones and I feel like I've wasted a month here without learning much. I'm unsubscribing.
Hi there, If you notice i have two types of playlists for topics - 1) Concepts Playlist - which teaches concept wise and qns are ordered as per concepts. 2) Qns playlist- which solves qns on that topic and hence it has to be a little random as the expectation is that one must have gone through concepts playlist. For example - I have created concepts and interview problems playlist for 1) Graph 2) Recursion 3) DP 4) Segment Tree Planning soon to create concepts playlist for Tree as well. Graph Concepts - ua-cam.com/play/PLpIkg8OmuX-LZB9jYzbbZchk277H5CbdY.html&si=lZG2IJTmSW4kRrx- Graph Popular Interview Problems - ua-cam.com/play/PLpIkg8OmuX-I_49pdy1XFY6OcATnxUrrO.html&si=CG2JvGWVmvoSqvWA Recursion Concepts - ua-cam.com/play/PLpIkg8OmuX-IBcXsfITH5ql0Lqci1MYPM.html&si=614iI4NyHY-FTeJH Recursion Problems (In progress) - ua-cam.com/play/PLpIkg8OmuX-IXOgDP_YYiJFqfCFKFBDkO.html&si=88fBhRnr62OYTnDP DP Concepts (In progress) - ua-cam.com/play/PLpIkg8OmuX-JhFpkhgrAwZRtukO0SkwAt.html&si=laFVYy6ep2BkOg0s DP Popular interview problems - ua-cam.com/play/PLpIkg8OmuX-L_QqcKB5abYynQbonaNcq3.html&si=VHEn9b-wqTnAVyyi Segment Tree Concepts - ua-cam.com/play/PLpIkg8OmuX-K1qUIQToCllUO0UIKXt8dB.html&si=xm7DqRN4H0eZwna4 But i respect your decision. I never force anyone to subscribe. Appreciate your time and apologies for inconvenience 😇❤️
bhai baaki comments bhi dekhle. I don't understand itna rude hone ka kya hai isme. public announce karke kya kehna chahte ho bhai. see MIK's reply above and I am shocked how humble this guy is.
Love u 💓 💗 💛 💖 ♥️ ❤ bro super explanation 👌
Thank you so much Kishan ❤️❤️
Brilliant explanation , No words. Thanks a ton.
Interesting things I learned while solving this question, (for those who are facing TLE while submitting)
1. Never mess with indexes ! If its 1 based index, do not forget to do -1. Also while marking flooded cells KEEP IN MIND that "i" should be Less than EQUAL to mid inside canCross() !
2. Always keep in mind to use the iterator with "&" while using the for loop.
I was using kind of -
for(auto dir: directions){..... }. which gave me lot of trouble. Before figuring this out I had 5 unsuccessful submits.
for(auto &dir: directions){..... } one solved the TLE issue.
Great playlist! Keep it up man! Thanks for good and easy explanation.
I solved it myself with both DFS and BFS after watching ur explanation 👌🏻
Awesome
Proud moment ❤️❤️
Thanks to you, today I solved this question by myself with BS + BFS ❤✨The Binary Search was a tricky part though !!
Great job! ❤️❤️
No one, literally no one can beat this channel 🔥
Love how you easily break such tough problems down!
Thank you so much ❤️❤️❤️
Got the June Badge. Thanks bhaiya for helping me to be consistent❤❤
So happy for you
Keep it up 💪💪💪
smooth as always... hard question kabhi hard lagta hi nahi jab aap explain krte ho ❤🛐
It means a lot to me ❤️❤️
Wonderful Explanation
Thank you 😊 ❤️
thanks for the explanation it was really helpful. the one 1 based indexing was messing up my logic.
I agree. 1based indexing was not required in the qn.
❤️❤️
Thanks to you I got June badge as well
Superb sir keep going😊😊😊😊
Thank you Saurav ❤️
Just GOAT❤
Means a lot ❤️❤️❤️
Please consider doing this problem using union find algorithm also
Feedback - Bro, spend a few minutes discussing time and space complexity.
As you know, time/space complexity can be a deal breaker in most interviews.
Noted Tarun.
Feedback taken.
Will definitely spend more time on TC and SC.
Actually i have been travelling this weekend and got to make this video somehow 😅
Thanks a lot ❤️. I am gonna note this for sure
@@codestorywithMIK Np bro..we understand maintaining this kind of consistency is really tough, along with our day-to-day duties. I really appreciate your efforts
Legendary 🔥
Solved it on my own thank you bro ❤
Awesome
I feel so proud and happier ❤️❤️
Best ❤
Thank you so much. I got my June Badge . yayyy
Thanks to you
Sir please can you solve this question using disjoint set... much in need.
Jo topic or kisi video se smj nhi ata bho apki vedio se ek baar me aa ja tha hai... I try to search the explananion....but or kisi ne nhi banaya...
sir please share the same question approch using disjoint set...
Ps: Apki video se hi smj att hai concept.
Actually i am already planning to make DSU video for this qn as well.
Give me some time as I am travelling hometown this week.
Coming next week for sure
@@codestorywithMIK
Thank You, waiting for your video :)
Bhaiya please koi recursion pr video bnayey jiise hm base case and recursion kb call krna
bro how do u make everything look so easy 🧡🧡🧡🧡
Means a lot ❤️
It's not clear where you reset the cells for new mid values.
Sir
I have been trying brute force approach since last few hours, but the output is always resulting in 0.
Can you please detect where am I going wrong?
class Solution {
public:
int lastDay = 0;
vector dir = {0, -1, 0, 1, 0};
bool dfs(int r, int c, int row, int col, vector& grid, vector& vis) {
if (r == row - 1 && c < col && grid[r][c] == 0)
return true;
if (r >= row || c >= col || r < 0 || c < 0 || vis[r][c] || grid[r][c] == 1)
return false;
vis[r][c] = 1;
for (int i = 0; i < 4; ++i) {
int dx = r + dir[i];
int dy = c + dir[i + 1];
if (dfs(dx, dy, row, col, grid, vis))
return true;
}
return false;
}
int latestDayToCross(int row, int col, vector& cells) {
int n = cells.size();
vector grid(row, vector(col, 0));
vector vis(row, vector(col, 0));
for (int i = 0; i < n; ++i) {
vector cellToWater = cells[i];
grid[cellToWater[0]-1][cellToWater[1]-1] = 1;
for (int j = 0; j < col; ++j) {
for (int ji = 0; ji< row; ++ji) {
for (int k = 0; k < col; ++k) {
vis[ji][k] = 0;
}
}
if (grid[0][j] == 0 && dfs(0, j, row, col, grid, vis) && !vis[0][j]) {
lastDay++;
break;
}
}
}
return lastDay;
}
};
Hi there,
Can you please check Animesh’s comment.
He has posted Brute force.
May be you can compare the code.
as always , nice explaination sir 💟, also can u please solve leetcode 952
Thank you 😊 ❤️
Sure let me plan that soon
Sir please live projects pe video layiiee ...
It would be helpful.
Hey
Thank you for the suggestion.
Would you like to share what kind of projects you are mentioning here ?
@@codestorywithMIK projects without web dev... intermediate ml projects... or any useful projects to put in resume.
Is that iPad? If yes, which one.
Ipad 11 pro
Brute Force Code
```
class Solution {
public:
int x[4]={1,-1,0,0};
int y[4]={0,0,1,-1};
bool canReach(int row,int col,int &m,int &n,vector &mat){
if(row
Wonderful
Thank you for sharing
I'm stopping here and shifting to Striver's channel. Your playlist misses a lot of important questions like Allocate Books, Painter's Partition, and Ship Packages. The questions seem to be randomly picked without any relation to the previous ones and I feel like I've wasted a month here without learning much.
I'm unsubscribing.
Hi there,
If you notice i have two types of playlists for topics -
1) Concepts Playlist - which teaches concept wise and qns are ordered as per concepts.
2) Qns playlist- which solves qns on that topic and hence it has to be a little random as the expectation is that one must have gone through concepts playlist.
For example -
I have created concepts and interview problems playlist for
1) Graph
2) Recursion
3) DP
4) Segment Tree
Planning soon to create concepts playlist for Tree as well.
Graph Concepts - ua-cam.com/play/PLpIkg8OmuX-LZB9jYzbbZchk277H5CbdY.html&si=lZG2IJTmSW4kRrx-
Graph Popular Interview Problems - ua-cam.com/play/PLpIkg8OmuX-I_49pdy1XFY6OcATnxUrrO.html&si=CG2JvGWVmvoSqvWA
Recursion Concepts - ua-cam.com/play/PLpIkg8OmuX-IBcXsfITH5ql0Lqci1MYPM.html&si=614iI4NyHY-FTeJH
Recursion Problems (In progress) - ua-cam.com/play/PLpIkg8OmuX-IXOgDP_YYiJFqfCFKFBDkO.html&si=88fBhRnr62OYTnDP
DP Concepts (In progress) - ua-cam.com/play/PLpIkg8OmuX-JhFpkhgrAwZRtukO0SkwAt.html&si=laFVYy6ep2BkOg0s
DP Popular interview problems - ua-cam.com/play/PLpIkg8OmuX-L_QqcKB5abYynQbonaNcq3.html&si=VHEn9b-wqTnAVyyi
Segment Tree Concepts -
ua-cam.com/play/PLpIkg8OmuX-K1qUIQToCllUO0UIKXt8dB.html&si=xm7DqRN4H0eZwna4
But i respect your decision. I never force anyone to subscribe. Appreciate your time and apologies for inconvenience 😇❤️
bhai baaki comments bhi dekhle. I don't understand itna rude hone ka kya hai isme. public announce karke kya kehna chahte ho bhai. see MIK's reply above and I am shocked how humble this guy is.