2850. Minimum Moves to Spread Stones Over Grid | With Harder Follow-up | Weekly Leetcode 362

แชร์
ฝัง
  • เผยแพร่เมื่อ 19 ก.ย. 2024

ความคิดเห็น • 14

  • @samieweee7468
    @samieweee7468 11 หลายเดือนก่อน +1

    I am still unable to understand how it is 2^D.We are still trying to map a zero cell with every possible available non zero cell. So isn't that still D!

  • @G-klips
    @G-klips 10 หลายเดือนก่อน

    Thanks, nice explanation

  • @HarishSumant
    @HarishSumant 11 หลายเดือนก่อน

    Out of the box solution!!
    Great!

  • @avalukagaorukavithai1079
    @avalukagaorukavithai1079 ปีที่แล้ว +1

    good explanation bro , realy nice one , after seeing your video , i can able to solve in python

  • @shibashisdolui7368
    @shibashisdolui7368 ปีที่แล้ว

    Please do a video for the last one. Not able to understand from the discussion. Got the intuition but then saw the constraints 😢

    • @codingmohan
      @codingmohan  ปีที่แล้ว

      Here you go - th-cam.com/video/dL2QbnqwUx4/w-d-xo.html

  • @AnandKumar-kz3ls
    @AnandKumar-kz3ls ปีที่แล้ว +1

    i tried mutisource bfs starting from 0 and reaching the nearest cell having extra stones and 566 / 611 test cases passed can you tell me your apporch why not to apply bfs here

    • @abdalrhmanserag7319
      @abdalrhmanserag7319 ปีที่แล้ว +3

      Because it's not greedy, multi source BFS won't guarantee the optimal answer. For example in this matrix:
      1 0 2
      1 2 1
      1 0 1
      The optimal result is 2 moves, however with multi source bfs, it might return 3 with this scenario:
      - Move 1 from cell (1,1) to the cell(0,1) -> cost is 1
      - Then move another 1 from the cell(0,2) to the cell(2,1) -> cost is 2
      - Then the total cost will be 1+2=3

    • @Anonymous____________A721
      @Anonymous____________A721 ปีที่แล้ว +1

      Wowww
      How did u find example that does not work!! 🔥🔥

    • @AnandKumar-kz3ls
      @AnandKumar-kz3ls ปีที่แล้ว +4

      ​@@abdalrhmanserag7319thanks for the explanation its really hard for me to come with correct approch the question was giving all the signs to apply bfs here like minimum moves ,matrix acting like weighted graph having all the edge weight equals to 1anyway i know we can try all the permutation but i go with the basic rules and ended up with wrong approch.

    • @vinayjangra1401
      @vinayjangra1401 ปีที่แล้ว

      bro, can you please share that solution, i want to understand, how can we try multisource bfs on this problem(even if it's not working)

  • @ashutoshjha2648
    @ashutoshjha2648 ปีที่แล้ว

    bhai awaj kam hai

  • @dayashankarlakhotia4943
    @dayashankarlakhotia4943 ปีที่แล้ว

    public class solution {
    public int minimum move(int [][]grid){
    //base case//
    int t=0;
    for(int i=0;i