Last Day Where You Can Still Cross | BFS | DFS | Binary Search | GOOGLE Onsite | Leetcode-1970

Поділитися
Вставка
  • Опубліковано 1 січ 2025

КОМЕНТАРІ • 57

  • @kishan.17
    @kishan.17 Рік тому +7

    Love u 💓 💗 💛 💖 ♥️ ❤ bro super explanation 👌

  • @iamnoob7593
    @iamnoob7593 2 місяці тому +2

    Brilliant explanation , No words. Thanks a ton.

  • @shreyaskulkarni245
    @shreyaskulkarni245 3 місяці тому

    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.

  • @anuppatankar4294
    @anuppatankar4294 Рік тому +4

    I solved it myself with both DFS and BFS after watching ur explanation 👌🏻

  • @prabhkiratsingh8793
    @prabhkiratsingh8793 Рік тому +5

    Thanks to you, today I solved this question by myself with BS + BFS ❤✨The Binary Search was a tricky part though !!

  • @thefinalfit
    @thefinalfit Рік тому +1

    No one, literally no one can beat this channel 🔥

  • @password47403
    @password47403 Рік тому +2

    Love how you easily break such tough problems down!

  • @neelx9437
    @neelx9437 Рік тому +2

    Got the June Badge. Thanks bhaiya for helping me to be consistent❤❤

  • @r.beditz3674
    @r.beditz3674 Рік тому +1

    smooth as always... hard question kabhi hard lagta hi nahi jab aap explain krte ho ❤🛐

  • @GeniusOG
    @GeniusOG Рік тому +1

    Wonderful Explanation

  • @floatingpoint7629
    @floatingpoint7629 Рік тому +3

    thanks for the explanation it was really helpful. the one 1 based indexing was messing up my logic.

    • @codestorywithMIK
      @codestorywithMIK  Рік тому

      I agree. 1based indexing was not required in the qn.
      ❤️❤️

  • @wearevacationuncoverers
    @wearevacationuncoverers Рік тому +1

    Thanks to you I got June badge as well

  • @sauravbiswajit8091
    @sauravbiswajit8091 Рік тому +1

    Superb sir keep going😊😊😊😊

  • @priyanshupandey3148
    @priyanshupandey3148 Рік тому +1

    Just GOAT❤

  • @gamersgame43
    @gamersgame43 25 днів тому

    Please consider doing this problem using union find algorithm also

  • @tarunstv796
    @tarunstv796 Рік тому +1

    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.

    • @codestorywithMIK
      @codestorywithMIK  Рік тому +1

      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

    • @tarunstv796
      @tarunstv796 Рік тому +1

      @@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

  • @FanIQQuiz
    @FanIQQuiz Рік тому

    Legendary 🔥

  • @codeandtalk6
    @codeandtalk6 Рік тому +1

    Solved it on my own thank you bro ❤

  • @shabananoor9423
    @shabananoor9423 Рік тому

    Best ❤

  • @souravjoshi2293
    @souravjoshi2293 Рік тому

    Thank you so much. I got my June Badge . yayyy
    Thanks to you

  • @codewalalove8783
    @codewalalove8783 Рік тому +2

    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.

    • @codestorywithMIK
      @codestorywithMIK  Рік тому +4

      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

    • @codewalalove8783
      @codewalalove8783 Рік тому +2

      @@codestorywithMIK
      Thank You, waiting for your video :)

  • @ram351
    @ram351 Рік тому

    Bhaiya please koi recursion pr video bnayey jiise hm base case and recursion kb call krna

  • @niteshshandilya4226
    @niteshshandilya4226 Рік тому +1

    bro how do u make everything look so easy 🧡🧡🧡🧡

  • @kalp2586
    @kalp2586 6 місяців тому

    It's not clear where you reset the cells for new mid values.

  • @shriyanshjain4444
    @shriyanshjain4444 Рік тому +2

    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;
    }
    };

    • @codestorywithMIK
      @codestorywithMIK  Рік тому

      Hi there,
      Can you please check Animesh’s comment.
      He has posted Brute force.
      May be you can compare the code.

  • @srijansrivastava890
    @srijansrivastava890 Рік тому +1

    as always , nice explaination sir 💟, also can u please solve leetcode 952

  • @M.m554
    @M.m554 Рік тому +1

    Sir please live projects pe video layiiee ...
    It would be helpful.

    • @codestorywithMIK
      @codestorywithMIK  Рік тому

      Hey
      Thank you for the suggestion.
      Would you like to share what kind of projects you are mentioning here ?

    • @M.m554
      @M.m554 Рік тому

      @@codestorywithMIK projects without web dev... intermediate ml projects... or any useful projects to put in resume.

  • @xiaoshen194
    @xiaoshen194 Рік тому +2

    Is that iPad? If yes, which one.

  • @animesh414
    @animesh414 Рік тому +3

    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

  • @NoneNobe-c3e
    @NoneNobe-c3e 4 місяці тому +1

    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.

    • @codestorywithMIK
      @codestorywithMIK  4 місяці тому +1

      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 😇❤️

    • @gui-codes
      @gui-codes 4 місяці тому +1

      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.