2658. Maximum Number of Fish in a Grid | leetcode daily challenge | shashcode | java | dsa

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

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

  • @shashwat_tiwari_st
    @shashwat_tiwari_st  2 дня назад +2

    like target for this video is 170. Please do like if you have understood the explanation as well as the code😊

  • @nikhilmalhotra1986
    @nikhilmalhotra1986 День назад

    Love the way you explain Shahswat. ♥♥

  • @NishantPandat-l3q
    @NishantPandat-l3q День назад

    nice explain sir

  • @sagnikbera4079
    @sagnikbera4079 День назад

    thnx a lot bhaiya, keep teaching like that.

  • @workAP-g5g
    @workAP-g5g День назад

    Thanks for the solution. Btw why dont u add ur face cam like older videos. it was cool.

  • @Mohammad-f8w4k
    @Mohammad-f8w4k День назад

    ♥♥♥♥♥♥

  • @DeepakSingh-ew3hi
    @DeepakSingh-ew3hi День назад

    Thank you so much 😃

  • @PiyushSharma-we8yd
    @PiyushSharma-we8yd 2 дня назад

    thankyou for the explanation ❤

  • @abhirajxyz7944
    @abhirajxyz7944 День назад +1

    class Solution:
    def findMaxFish(self, grid: List[List[int]]) -> int:
    row = len(grid)
    col = len(grid[0])
    visited = [[False]*col for _ in range(row)]
    ans = 0
    # first start with the land
    for i in range(row):
    for j in range(col):
    if grid[i][j]>0 and not visited[i][j]:
    ans = max(ans,self._dfs(grid,visited,i,j))
    return ans
    def _dfs(self, grid:List[List[int]],visited:List[List[bool]], i:int, j:int) -> int:
    if i < 0 or j < 0 or i >= len(grid) or j >= len(grid[0]) or visited[i][j] or grid[i][j] == 0:
    return 0
    visited[i][j] = True
    current_part = grid[i][j] + self._dfs(grid,visited,i+1,j) + self._dfs(grid,visited,i-1,j) + self._dfs(grid,visited,i,j+1) + self._dfs(grid,visited,i,j-1)
    return current_part

  • @KedarBhawthankar
    @KedarBhawthankar День назад +1

    08:13 definately error because of if row or col are out of grid then how can you access then

  • @manishchauhan4630
    @manishchauhan4630 День назад

    this problem is exactly the same as 1219. Path with Maximum Gold just without backtracking

  • @PiyushSharma-we8yd
    @PiyushSharma-we8yd 2 дня назад

    first

  • @devnarula6733
    @devnarula6733 2 дня назад

    error due to not-shortcircuit of grid[r][c] will come