Leetcode 1937 Maximum Number of Points with Cost

Поділитися
Вставка
  • Опубліковано 16 гру 2024

КОМЕНТАРІ • 61

  • @auto8ot644
    @auto8ot644 2 роки тому +12

    I really like how you explained the question using Leetcode 931 and 1014 as support to explain 1937. Thanks for the video!

  • @rohanthakur9159
    @rohanthakur9159 4 місяці тому

    Thanks for explaining by connecting 3 problems. Awesome content🔥🔥🔥

  • @chetansahu1505
    @chetansahu1505 3 роки тому +2

    @3:50 I stopped the video here and went to solve leetcode 931 (nicely done in one go) and leetcode 1014 as well (realized I solved it earlier). I got some ideas to handle now 1937 but still in a little muddle.

    • @sandip_jana
      @sandip_jana  3 роки тому

      Ok thanks for feedback. So where exactly do you have doubts? Which part of the problem you didn't understand?

    • @blasttrash
      @blasttrash 2 роки тому

      @@sandip_jana link not working

    • @sandip_jana
      @sandip_jana  2 роки тому

      Hi. Yes it wont work. let me know if you have any specific doubts. i will try to answer them here

    • @sandip_jana
      @sandip_jana  2 роки тому

      github.com/Sandip-Jana/UA-cam/blob/main/MaximumNumberOfPointsWithCost.txt

  • @srndrpec
    @srndrpec 2 роки тому

    one shot, three problems...good approach

  • @mitasingh1553
    @mitasingh1553 2 роки тому

    if it is abs diff. then it will always return a positive value then why j< k or j>k matters?

  • @rohithkumargattu6749
    @rohithkumargattu6749 3 роки тому +1

    Thank you so much! It is a great explanation, sir, definitely I am gonna share this video and channel with all my friends to watch, it is really helpful. please solve the problems consistently, definitely, it will help lots of people and this channel definitely gonna rock

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

    great explanation. Keep up with the good work

  • @ShivangiSingh-wc3gk
    @ShivangiSingh-wc3gk 2 роки тому +1

    Such a great way to tackle DP write mathematical equations and then break it apart.

  • @Adrian-xe2sn
    @Adrian-xe2sn 2 роки тому

    Could you potentially explain how you got case 2 : -j < k? Like why is it -j?

    • @sandip_jana
      @sandip_jana  2 роки тому +1

      No No. I wrote it as
      Case 2 :- j < k
      Its not -j haha sorry for the trouble :)

  • @nurshuvo3854
    @nurshuvo3854 2 роки тому

    Thanks man. I like the way you explained.

  • @Shivang-t3m
    @Shivang-t3m 5 місяців тому +1

    Nice Explanation, thanks

  • @ganeshjaggineni4097
    @ganeshjaggineni4097 4 місяці тому

    NICE SUPER EXCELLENT MOTIVATED

  • @ankitmishra399
    @ankitmishra399 2 роки тому

    hey can u optimize memiozed approach code attach below

    • @ankitmishra399
      @ankitmishra399 2 роки тому

      class Solution {
      Long dp[][];
      public long maxPoints(int[][] mat) {
      long max=0;
      dp=new Long[mat.length][mat[0].length];
      for(int j=0;j

  • @ShivangiSingh-wc3gk
    @ShivangiSingh-wc3gk 2 роки тому

    Great Explanation, thank you

  • @ankurshah3112
    @ankurshah3112 2 роки тому

    Very good explanation. Thank you

  • @paragroy5359
    @paragroy5359 3 роки тому

    Nice explanation.........thanks for the video...

  • @yhdzhang
    @yhdzhang 3 роки тому

    Thanks. Really good explanation. My question is how am I meant to come up with these math equations if I haven't seen the question before

    • @sandip_jana
      @sandip_jana  2 роки тому +1

      Good question! Actually this comes with practice . the more problems we solve the better we become

  • @souravadhikari7485
    @souravadhikari7485 3 роки тому

    Can you please explain
    rightMax[m-1] = dp[i-1][m-1] - (m-1);
    Why do we take -(m+1) part in your code?

    • @sandip_jana
      @sandip_jana  2 роки тому +1

      Its simple :
      the state is :
      --> dp[i-1][k] - k
      so when k == m-1
      we will have
      --> dp[i-1][m-1] - (m-1)
      we simply replace k with m-1. because the last column is denoted by m-1

  • @chetansahu1505
    @chetansahu1505 3 роки тому

    Many people like me come on UA-cam, post leetcode contest to help themselves upsolve the unsolved problems. So if you could make videos of all 4 problems after every contest that would be of great help. Thanks brother for such a great explanation.

    • @sandip_jana
      @sandip_jana  3 роки тому +3

      I will try. I am still struggling to explain properly in my videos as evident from the bloopers :D . But yeah i will try :)

  • @TheIndianChroniclee
    @TheIndianChroniclee 3 роки тому

    Very Nice Explaination ..

  • @nribackpacker
    @nribackpacker 2 роки тому

    very good explanation appreciated

  • @ShivangiSingh-wc3gk
    @ShivangiSingh-wc3gk 2 роки тому +1

    Came back to it in the morning, I am still failing to understand that how it is O(nm)

    • @ShivangiSingh-wc3gk
      @ShivangiSingh-wc3gk 2 роки тому

      Don't we have to do all the values of k

    • @sandip_jana
      @sandip_jana  2 роки тому

      Correct we have to do it for all values of k. and what does k signify??
      Case 1 : j > k
      so k = ( 0,1,.... j-2 , j-1 )
      Case 2 : j < k
      so k = ( j+1 , j+2 ..... m-1 )
      So k is the number of columns we have.
      So for each row we simply precompute the leftPrefixMaximum for all values of `k`.
      And the rightSuffixmaximum for all values of `k`.
      Finally we calculate the best answer for all current row.
      Hence time complexity = O( n * ( m + m + m ) ) ~ O ( n*m )
      Let me know if you have any doubts
      Solution for reference : github.com/Sandip-Jana/UA-cam/blob/main/Leetcode1937.java

  • @dsacp7570
    @dsacp7570 3 роки тому

    today i solved sightseeing one, got stuck in contest though for this.

  • @RG-yj4cb
    @RG-yj4cb 3 роки тому +1

    todu ho bhai, 15 min teen questions chaap diye!

  • @motivation_hubPJ
    @motivation_hubPJ 3 роки тому

    Very nice explanation thanks a lot !

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

    very good explanation.

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

    what about the case j == k?

  • @BRBallin1
    @BRBallin1 2 роки тому +1

    Sorry but I didn't understand the problem still based on your explanation. It focused too much on the notations but should've done a walkthrough with the logic directly per iteration

    • @sandip_jana
      @sandip_jana  2 роки тому

      No worries. I am trying to explain in a better way

  • @rupayanghosh150
    @rupayanghosh150 3 роки тому

    Great explanation

  • @nipunaggarwal7568
    @nipunaggarwal7568 3 роки тому

    Sir, amazing explanation

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

    You are op🎉🎉

  • @AnkitKumar-po4wx
    @AnkitKumar-po4wx 3 роки тому

    nice explanation

  • @aviralarpan7350
    @aviralarpan7350 2 роки тому

    Thanks a lot

  • @niteshsaxena1066
    @niteshsaxena1066 4 місяці тому

    good

  • @harshalgarg1149
    @harshalgarg1149 3 роки тому

    Thanks a lot.

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

    POTD gang?

  • @HarendraKumar-hl8nh
    @HarendraKumar-hl8nh 3 роки тому

    Sir, Please upload beautiful problems on Dp and please continue teaching on white board. 🙏🙂 I am eagerly waiting... for your upcoming videos on Dp.

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

    Too Great ! XD

  • @shaikhkamran532
    @shaikhkamran532 3 роки тому

    best of what? when you explain explain it clearly please

    • @sandip_jana
      @sandip_jana  3 роки тому +1

      I am trying to improve my explanation. You may try to read other explanations in the discussion forum of problem for better idea. Hope that helps.

  • @ishaankaustav727
    @ishaankaustav727 2 роки тому

    💚💚

  • @vardhanyash243
    @vardhanyash243 5 місяців тому

    noice