Map of Highest Peak - Leetcode 1765 - Python

Поделиться
HTML-код
  • Опубликовано: 1 фев 2025

Комментарии • 33

  • @prajwals8203
    @prajwals8203 11 дней назад +2

    00:34 Add 542. 01 Matrix to the list

  • @deadlyecho
    @deadlyecho 11 дней назад +11

    No need for a visiting set, right? We can check if the cell is not negative

  • @ramez3038
    @ramez3038 10 дней назад

    Thank u for your efforts neetcode 😀😀

  • @user-my6yf1st8z
    @user-my6yf1st8z 10 дней назад

    thanks boss, you did it again

  • @rdtyphon6684
    @rdtyphon6684 11 дней назад +2

    14:14 sorry im very new, we are using while q for the while condition and we are also appending nr and nc in it, wouldnt this mesn that q will never be empty, and the while loop would run inderinitely

    • @pyrohugs
      @pyrohugs 11 дней назад +4

      No, since visited nodes are marked and never added to the queue more than once.

    • @AznofHK
      @AznofHK 10 дней назад

      set a breakpoint and run the loop step by step to see how the values are updated :D

    • @marceloaugusto633
      @marceloaugusto633 10 дней назад

      You dont always append, so eventually the queue will be empty

    • @codygao8323
      @codygao8323 10 дней назад +1

      Maybe your are not yet prepared for medium questions like this if you are not fully understand the basics. Try some easy questions first can build up the confidence.

  • @TaeJoonKim-y1d
    @TaeJoonKim-y1d 10 дней назад

    Hi, thanks so much for your video on daily leet code problems. I have been working on daily leetcode problems through your videos. I tried to work on this problem earlier. I figured out the logic behind that I need to check water cells, fill in adjacent cells to water cells to 1 and fill out the other cells by increasing 1 to the minimum number of adjacent cells. However, I could not connect this problem with BFS. Also, i understand how BFS algorithm works but I am having issue with applying it to the problems. What are the basic problems that I can practice applying BFS and how do I get better with figuring out algorithm by looking at any problem?

  • @skanderbegvictor6487
    @skanderbegvictor6487 11 дней назад

    thanks, I was able to do this after seeing the topics and second hint

  • @akashdeshpande4350
    @akashdeshpande4350 10 дней назад

    Thanks!

  • @akshayvishwakarma188
    @akshayvishwakarma188 10 дней назад

    Thank you

  • @pastori2672
    @pastori2672 11 дней назад

    multi source bfs is not that common but i feel like it's a very intruitive/useful algorithm

  • @yhbarve
    @yhbarve 11 дней назад +1

    He predicted this question a couple of days ago!

    • @JamesBond-mq7pd
      @JamesBond-mq7pd 11 дней назад +1

      how?

    • @yhbarve
      @yhbarve 11 дней назад

      ​@@JamesBond-mq7pd Leetcode Daily follows a pattern. The last few questions have been about 2D grids / graphs.

    • @JamesBond-mq7pd
      @JamesBond-mq7pd 11 дней назад

      @@yhbarve how he knew that it is gonna be this specific question?

    • @AbdoSharafDev
      @AbdoSharafDev 10 дней назад

      @@JamesBond-mq7pd LeetCode releases the editorial for the daily questions a few days before they are the daily questions, he mentioned this in an old video btw.

  • @diegomunoz5139
    @diegomunoz5139 11 дней назад +1

    he stays grinding

  • @_night_spring_
    @_night_spring_ 10 дней назад +1

    Got a simple bfs for the first time and I don't think it has any optimization

  • @business_central
    @business_central 11 дней назад +5

    Can't believe I got it by myself .... Thank you so much Neet!

  • @christian_nardi
    @christian_nardi 10 дней назад

    I tried to code this in js but gives me time limited exceeded...
    here's the code, I don't know how to improve it
    var highestPeak = function(isWater) {
    let [m, n] = [isWater.length, isWater[0].length]
    let res = new Array(m).fill(0).map(e=> new Array(n).fill(-1))
    let q = []
    for(let i=0; i-1 && y>-1 && x

  • @sauravsingh4497
    @sauravsingh4497 10 дней назад +2

    the guy that wrote that description should be fired

    • @user-my6yf1st8z
      @user-my6yf1st8z 10 дней назад +1

      nah it was alright

    • @sauravsingh4497
      @sauravsingh4497 10 дней назад

      @user-my6yf1st8z not for me after seeing neetcode's explaination of the problem description I was able to solve it pretty quickly on my own

  • @lucasonyiego4132
    @lucasonyiego4132 11 дней назад +7

    I take the first comment today

  • @staywithmeforever
    @staywithmeforever 11 дней назад

    Bfs sucks for this problem