Minimum Falling Path Sum - Leetcode 931 - Python

Sdílet
Vložit
  • čas přidán 28. 07. 2024
  • 🚀 neetcode.io/ - A better way to prepare for Coding Interviews
    🧑‍💼 LinkedIn: / navdeep-singh-3aaa14161
    🐦 Twitter: / neetcode1
    ⭐ BLIND-75 PLAYLIST: • Two Sum - Leetcode 1 -...
    Problem Link: leetcode.com/problems/minimum...
    0:00 - Read the problem
    0:30 - Recursive Explanation
    3:35 - Recursive Coding
    8:00 - DP Explanation
    10:42 - DP Coding
    leetcode 931
    #neetcode #leetcode #python

Komentáře • 29

  • @user-pv4xn3sg7j
    @user-pv4xn3sg7j Před 6 měsíci +20

    Missed your daily videos bro.

  • @runabishek
    @runabishek Před 6 měsíci +20

    Please don't skip posting videos😅

    • @dingus2332
      @dingus2332 Před 6 měsíci

      To be fair , questions asked in that time frame , were not that deep

  • @surajmandal_567
    @surajmandal_567 Před 6 měsíci +16

    Let's write some more neetcode 🎉.

    • @tekfoonlim4745
      @tekfoonlim4745 Před 6 měsíci

      I use subtitles always.. and it gives let's write some neat code 😂😂

  • @MP-ny3ep
    @MP-ny3ep Před 6 měsíci +1

    Great explanation as always. Thank you very much.

  • @shashankgupta5192
    @shashankgupta5192 Před 6 měsíci +4

    Finally you are back!!❤

  • @aksharpathak5226
    @aksharpathak5226 Před 6 měsíci

    thanks bro for uploading the video.......I thought you stopped solving leetcode

  • @ahmedtremo
    @ahmedtremo Před 6 měsíci

    Welcome back :D

  • @rahulchauhan.
    @rahulchauhan. Před 6 měsíci

    One can adapt this problem to find the maximum falling path too!

  • @LeetCodeUzbekistan
    @LeetCodeUzbekistan Před 6 měsíci +1

    bro in the moring I looked for your video, I could solve this by my own and then you publishing this video which is the exact same algorithm 😅

  • @mrgeorgy93
    @mrgeorgy93 Před 6 měsíci

    I got my Amazon offer yesterday, largerly thanks to your channel!

  • @dumbfailurekms
    @dumbfailurekms Před 6 měsíci +1

    sometimes u are literally the only light in my eternal dark hell

  • @Dancedfsk8
    @Dancedfsk8 Před 6 měsíci

    Finally!

  • @alviahmed7388
    @alviahmed7388 Před 6 měsíci

    When will you stream next?

  • @justintang6313
    @justintang6313 Před 6 měsíci

    Is the DP solution top-down or bottom-up?

  • @Pegasus02Kr
    @Pegasus02Kr Před 6 měsíci

    Is it truly a solution for medium difficulty problem? was much harder to understand than most of hard problem for me..

  • @Itachi-mr8nj
    @Itachi-mr8nj Před 6 měsíci +1

    Bro is gonna pretend like he didn't go missing for a few days

  • @imretakacs8952
    @imretakacs8952 Před 6 měsíci

    At line 8, should not that be c >= 0 instead of c > 0.

  • @mikerico6175
    @mikerico6175 Před 6 měsíci

    Could do += line 10 and use inf instead of float(“inf”)

    • @phatboislym
      @phatboislym Před 6 měsíci

      what is "line 10"?

    • @mikerico6175
      @mikerico6175 Před 6 měsíci

      @@phatboislymmatrix[r][c] = matrix[r][c] + …. instead just do matrix[r][c] +=

    • @user-vs1jd4kp4h
      @user-vs1jd4kp4h Před 6 měsíci

      @@phatboislym you can avoid by managing index inside the indexing as well like this:
      I used extra dp matrix but you can use the same input array to do this as well
      def minFallingPathSum(self, matrix: List[List[int]]) -> int:
      m, n = len(matrix), len(matrix[0])
      dp = [[0 for _ in range(n)] for _ in range( m+1)]
      for i in range(m-1, -1, -1):
      for j in range(n):
      dp[i][j] =min(matrix[i][j]+dp[i+1][max(0,j-1)], matrix[i][j]+dp[i+1][j], matrix[i][j]+ dp[i+1][min(n-1,j+1)])
      return min(dp[0])

  • @XEQUTE
    @XEQUTE Před 6 měsíci +1

    Please do daily neetcode problems or update the community posts with links to earlier solved problems please
    I do not want to watch any other channel

  • @user-sj1fk4vs3n
    @user-sj1fk4vs3n Před 6 měsíci

    why i am getting tle???
    class Solution {
    public int minFallingPathSum(int[][] matrix) {
    int n=matrix.length,m=matrix[0].length;
    int min=Integer.MAX_VALUE;
    int dp[][]=new int[n][m];
    for(int row[]:dp)
    {
    Arrays.fill(row,-1);
    }
    for(int i=0;i

  • @elyababakova2125
    @elyababakova2125 Před 6 měsíci

    A nice problem to revise classic DP solutions. Thanks for video, I was missing your daily solutions!
    BTW @NeetCodeIO, I wonder wether you've bought a leetcode T-Shirt for leetcoins? :)

  • @aksimsons
    @aksimsons Před 6 měsíci

    Anyone getting TLE for running recursive solution in Java?
    This is my code:-
    class Solution {
    public int dfs(int row,int column,int[][] matrix,HashMap s){
    int n=matrix.length;
    if(row==n )
    return 0;
    if(column==n || column