DP 14. Subset Sum Equals to Target | Identify DP on Subsequences and Ways to Solve them

แชร์
ฝัง
  • เผยแพร่เมื่อ 8 ก.ค. 2024
  • Lecture Notes/C++/Java Codes: takeuforward.org/data-structu...
    Problem Link:bit.ly/3ukNmRZ
    Pre-req for this Series: • Re 1. Introduction to ...
    a
    Make sure to join our telegram group for discussions: linktr.ee/takeUforward
    Full Playlist: • Striver's Dynamic Prog...
    In this video, we solve the problem subsets sum equal to K. This problem is the first problem on DP on Subsequences Pattern. Please watch this video to have a clear concept of take/notTake concept.
    If you have not yet checked our SDE sheet, you should definitely do it: takeuforward.org/interviews/s...
    You can also get in touch with me at my social handles: linktr.ee/takeUforward

ความคิดเห็น • 1K

  • @takeUforward
    @takeUforward  2 ปีที่แล้ว +169

    I need your support, and you can do that by giving me a like, and commenting "understood" if I was able to explain you.
    Note: Please add a check for arr[0]

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

      Just love the meta of solving subsequences by "take" and "not-take" :) A big US!!!

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

      Understood Sir

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

      i think subset sum also can be done using only one array......as you did in knapsack problem....

    • @anonymousvoid6356
      @anonymousvoid6356 2 ปีที่แล้ว

      Huge big understood!!!!

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

      mera full support bhai 👍👍👍

  • @ankitadas5833
    @ankitadas5833 2 ปีที่แล้ว +147

    Understood! you ended the video by submitting space optimization code at Morning 02:53 AM,,,,, How much energy you have 😱😱😱😱. Hats off to your dedication.

    • @takeUforward
      @takeUforward  2 ปีที่แล้ว +57

      Thanks for noticing ♥️

    • @RajeevKumar-fb3in
      @RajeevKumar-fb3in 2 ปีที่แล้ว +4

      😱😱

    • @RajeevKumar-fb3in
      @RajeevKumar-fb3in 2 ปีที่แล้ว +23

      You also saw his video 02:53 AM😱

    • @shiblijamal8544
      @shiblijamal8544 9 หลายเดือนก่อน +11

      3am is like heaven time to code❤

    • @lakshsinghania
      @lakshsinghania 8 หลายเดือนก่อน

      @@shiblijamal8544 can't stress more on this

  • @tanmay9928
    @tanmay9928 ปีที่แล้ว +87

    Had to watch the video multiple times in order to fully understand this concept. In all seriousness, there are so many key points to be kept in mind when learning this concept.

    • @charanteja2407.
      @charanteja2407. 10 หลายเดือนก่อน

      Can anyone list those key points here

  • @nityanandbhaskar2155
    @nityanandbhaskar2155 ปีที่แล้ว +32

    Just a edge case correction. dp[0][arr[0]] could give out of bound exception if arr[0] > target. So use a check for that.

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

      that won't be an edge case as initially the whole dp is marked false in tabulation method

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

      ​@@devsrivastava2300 that will be an edge case if arr[0] is greater than the half of total sum then it will be out of bounds

    • @jayendraawasthi2646
      @jayendraawasthi2646 ปีที่แล้ว +4

      @@devsrivastava2300 assume arr[0] = 1000 and target is 10. It will give error.

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

      Oh ok got it , thanks

    • @muditkhanna8164
      @muditkhanna8164 9 หลายเดือนก่อน

      keen observation.

  • @chetanthakral5322
    @chetanthakral5322 2 ปีที่แล้ว +123

    I think he is missing a if case , if arr[0] >=k , then we would be getting a sigsegv runtime error.
    To remove that we can replace dp[0][arr[0]] = true; by
    if(arr[0]

    • @takeUforward
      @takeUforward  2 ปีที่แล้ว +40

      Corrected in the next video. Thanks.

    • @elements8630
      @elements8630 2 ปีที่แล้ว +7

      I was confused about this part. thanks, bud!

    • @rishabhtater889
      @rishabhtater889 ปีที่แล้ว +2

      but why in the first place dp[0][arr[0]]=true is mentioned?

    • @pk4288
      @pk4288 ปีที่แล้ว +5

      @@rishabhtater889 when we reach index 0 and target left is equal to arr[0] then only we will return true otherwise it will be false. so in tabulation we are initializing like that only

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

      @@pk4288 so in tabulation, we are assuming it to be true only?
      Then we'll move forward?

  • @k4ranjith
    @k4ranjith 2 ปีที่แล้ว +10

    Understood, Very well explained. the best DP playlist. Thanks for taking time and making the videos.

  • @kevinthant2952
    @kevinthant2952 6 หลายเดือนก่อน +1

    So far to me, you are the best explainer of algorithm questions on the whole Internet. Thank you so much for your amazing work on these explanation videos. 🙏🙌

  • @nagame859
    @nagame859 10 หลายเดือนก่อน +1

    understood!
    just the recurrence tree is enough to understand this problem.. which again.. you explained it in the best way in the recursive series.. props to you 👏 🙌 🙏

  • @priyanshubansal6820
    @priyanshubansal6820 2 ปีที่แล้ว +4

    This is the best dp solving technique that I have ever seen. thank you for giving us this wonderful playlist

  • @dsp-io9cj
    @dsp-io9cj 9 หลายเดือนก่อน +6

    dp[0][arr[0]]=1; in this what if arr[0] is greater than target, coz given constraints are arr[i]

    • @AD-fs6hr
      @AD-fs6hr หลายเดือนก่อน

      Correct. I suppose the test cases in Coding Ninjas are made such that, target is always greater than first element. otherwise it would have thrown error.

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

    At first I thought your methos is very obvious, but as we go further in dp playlist it proves to be much stronger tool to apply for solving tough problems.

  • @swapan6785
    @swapan6785 6 หลายเดือนก่อน +2

    Nicely explained! Had to do dry run multiple times for full understanding.
    It seems very tough to directly write tabulation/space optimization method, but easy when starting from recursion and following the order.

  • @lambar0
    @lambar0 ปีที่แล้ว +8

    Your energy and passion for breaking it down is commendable… thanks

    • @user-cl3un2qx7s
      @user-cl3un2qx7s 2 วันที่ผ่านมา

      in tabulation
      why dp[0][arr[0] ] is equal to true

    • @user-cl3un2qx7s
      @user-cl3un2qx7s 2 วันที่ผ่านมา

      understood

  • @ajith4249
    @ajith4249 9 หลายเดือนก่อน +7

    Tabulation burra padu . Super oo

  • @aarushirai6374
    @aarushirai6374 2 ปีที่แล้ว

    Understood. Brilliantly explained. You clear the concepts to the core.

  • @oliverlowcy
    @oliverlowcy 2 ปีที่แล้ว +2

    Had trouble understanding bottom up approach till I saw this vid. Thanks a lot!

  • @roshangupta8161
    @roshangupta8161 ปีที่แล้ว +9

    Understood each and everything!!!Thanks for this amazing Dp series.

    • @Abhijeet-st4bj
      @Abhijeet-st4bj ปีที่แล้ว

      bhai why dp[ind+1][target+1]?? why not dp[ind+1][target+1]??

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

      @@Abhijeet-st4bj do you mean why not dp[ind][target] ??

  • @arpitrajput6424
    @arpitrajput6424 2 ปีที่แล้ว +7

    hey! we can add one more line to reduce further looping if we get our ans
    add if(dp[ind][k]==true)return true;
    at before end of second loop try it.
    vector dp(n,vector(k+1,false));

    for(int i=0;i

  • @ParodyCSEDept
    @ParodyCSEDept 3 หลายเดือนก่อน +2

    Tbh in most of the previous 13 problems, I was intuitively able to guess the DP recurrence relation (without thinking about recursion and all). However for this question, intuition didn't kick in. Then, I remembered your words that if I can write a recursive solution for the problem then after following your steps, I will be able to reach the DP solution. So I did follow all the steps and yeah I really was able to reach the most optimal solution for this on my own. Hats off to you Striver!
    Understood!

  • @piyushsaxena6243
    @piyushsaxena6243 2 ปีที่แล้ว +2

    understood, this is the best dp playlist indeed

  • @MohammadKhan-ld1xt
    @MohammadKhan-ld1xt ปีที่แล้ว +15

    Before starting this dp series, I was really confused as to which playlist I should follow as there were many good playlist , but after listening to first 2 lectures, I knew that this is the best dp playlist I could ever find and this includes the paid courses too. I have paid courses but I prefer this.
    I am addicted to this playlist. Seriously!!! Hats of to you bhaiyya🔥Keep striving and good luck. Hope to see you on the right path..

  • @zeroanims4113
    @zeroanims4113 ปีที่แล้ว +8

    27:58 this is a very important point to understand. I wrote the recursion slightly different from striver (i start from 0 -> N) meaning the top of my recursion is 0 and the bottom is N. So my dp bottom up nested loop is from n-1 going to 0, and will return dp[0[[k], it should still work
    code:
    bool dpWay(int n, int k, vector& arr){
    vector dp(n+1, vector(k+1, false));
    for (int i = 0; i = 0; i--){
    for (int j = 1; j = arr[i]) take = dp[i+1][j-arr[i]];
    dp[i][j] = skip || take;
    }
    }
    return dp[0][k];
    }
    bool rcMemoWay(int i, vector& nums, int tar, vector& memo){
    if (tar == 0) return true;
    if (i == nums.size()) return false;
    if (memo[i][tar] != -1) return memo[i][tar];
    bool skip = rcMemoWay(i+1, nums, tar, memo);
    bool take = false;
    if (tar >= nums[i]) take = rcMemoWay(i+1, nums, tar - nums[i], memo);
    memo[i][tar] = skip || take;
    return memo[i][tar];
    }

    • @GauravThinks
      @GauravThinks 5 หลายเดือนก่อน +1

      yahi dhund raha tha mai bhai ♥

  • @stith_pragya
    @stith_pragya 6 หลายเดือนก่อน +1

    UNDERSTOOD..................Thank You So Much for this wonderful video..........🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻

  • @rijumondal6876
    @rijumondal6876 6 หลายเดือนก่อน +1

    He is probably one of the most genius guy I ever come across

  • @Rohit-zk1lz
    @Rohit-zk1lz 11 หลายเดือนก่อน +8

    "what's bottom up ulta ulta"

  • @RahulKushwah-sv9rh
    @RahulKushwah-sv9rh 2 ปีที่แล้ว +3

    Raj bhaiya rocks ☄☄☄ from beginning to this video I never felt that this is the same topic in which previously I faced a lot of problem to solved the question.

    • @takeUforward
      @takeUforward  2 ปีที่แล้ว +8

      Areh video th dekh lo :|

    • @RahulKushwah-sv9rh
      @RahulKushwah-sv9rh 2 ปีที่แล้ว

      Woh toh smj aa hi jayegi bhaiya aap Padhye ho😀

  • @priyanshuchouhan9845
    @priyanshuchouhan9845 10 หลายเดือนก่อน +1

    the lecture was amazing . This took my concept of dp at next level.

  • @SriAdiNarayanaReddySabbella
    @SriAdiNarayanaReddySabbella 13 วันที่ผ่านมา +1

    Understood! Tabulation is tricky in this one a little bit. But, your explanation just made it so easy. Thank you so much for this amazing series ❤

  • @rahulpothula1902
    @rahulpothula1902 2 ปีที่แล้ว +7

    Everything understood perfectly!! But a small doubt in tabulation: why did we directly write dp[0][arr[0]] = true without checking the condition if(arr[0] == k)???
    Pls pls pls answer if anyone knows....🙏

    • @aaryan3461
      @aaryan3461 2 ปีที่แล้ว

      same doubt

    • @codingachinilgtifirbhikrrh9009
      @codingachinilgtifirbhikrrh9009 2 ปีที่แล้ว +2

      it is a
      reminiscence of the base condition which we used in recursion i.e. if(i==0)return arr[0] = target

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

      dp[0][arr[0]] means n=0, means only 1 element i.e., arr[0] present in array and the target is arr[0]. Since target and element is same it is true. I feel 1 based indexing is more easy to understand, see Aadity verma videos for it.

    • @abhishekgururani6993
      @abhishekgururani6993 2 ปีที่แล้ว +4

      Listen, in your base case for recursion you had condition that when "index will be 0" and "value of arr[0] will be equal to target" you'll return true. In tabulation, dp is represented like this : dp[index][target], so the value of dp when "index equals 0 and target equals arr[0]" is true;

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

      Same Doubt...........as arr[0] can be any large value then how can we take it as index of a fixed size dp??

  • @aman9633
    @aman9633 2 ปีที่แล้ว +7

    What if n=1,k=5 and arr[0]=10 ,when we are doing pre[arr[0]] ,as arr[0]>k won't it go out of bounds??

    • @takeUforward
      @takeUforward  2 ปีที่แล้ว +7

      Yes true, correctly pointer out. Thanks. For that reason we need to write another check condition.

    • @satyamraj2779
      @satyamraj2779 17 วันที่ผ่านมา

      or rather you can just do this
      for(int i = 0; i

  • @shivambajaj7640
    @shivambajaj7640 2 หลายเดือนก่อน

    In two days, I am able to convert my recursive solutions to iterative. All thanks to you!

  • @dharmeshpoladiya9047
    @dharmeshpoladiya9047 2 ปีที่แล้ว

    Understood 💯💯 Great Explanation. Thank you very much for all you efforts🔥🔥

  • @amitghosh4548
    @amitghosh4548 2 ปีที่แล้ว +6

    I've submitted the Top-Down version with 1D memo and still got accepted...
    vector memo;
    bool knapSack(int i, int sum, int K, vector &A) {
    if (i < 0)
    return false;

    if (sum >= K)
    return sum == K;

    if (memo[i] != -1)
    return memo[i];

    if (knapSack(i - 1, sum + A[i], K, A) || knapSack(i - 1, sum, K, A))
    memo[i] = 1;

    return memo[i] == 1;
    }
    bool subsetSumToK(int N, int K, vector &A) {
    memo.assign(N, -1);
    return knapSack(N - 1, 0, K, A);
    }

    • @sushant8686
      @sushant8686 2 ปีที่แล้ว

      i don't how this is working because for index we two choices how will you know which choice is giving me right and which is giving wrong ?

  • @anything_jara_hatke5237
    @anything_jara_hatke5237 2 ปีที่แล้ว +7

    When I took a 2D global vector of size n*k max values i.e 1e3*1e9, I am getting Segment error. But when I don't define it globally and take it as a parameter of function, than it is working fine, can I get its explanation please.

  • @lalitchahar1068
    @lalitchahar1068 5 หลายเดือนก่อน

    it took time to understand it but it worth every second
    fabulous explaination thank you soo much for these high quality videos..🤗

  • @ramyasree4986
    @ramyasree4986 2 ปีที่แล้ว

    in recursion time complexity is always no of changing states and possibilities (all stuffs) this we further reduce from exponential using memorization and with tabulation we remove stack space and with space optimisation we do reduce array dimension woww!!!! so clear explanation

  • @snipercool4169
    @snipercool4169 ปีที่แล้ว +7

    [Java] Tabulation Solution :
    public class Solution {
    public static boolean subsetSumToK(int n, int k, int arr[]){
    // Declaring dp array.
    boolean dp[][] = new boolean[n + 1][k + 1];
    // If required sum = 0, answer always true.
    for (int i = 0; i

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

      one issue you have to also add else dp[i][j]=dp[i-1][j]

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

    Value of k is max 1e9 and N is 1e3, I don't think we can take 2D array as dp instead of vector, right?

  • @priyanshuchouhan9845
    @priyanshuchouhan9845 10 หลายเดือนก่อน +1

    I understood all the concepts that you taught in this lecture

  • @sairam3351
    @sairam3351 7 หลายเดือนก่อน +1

    Understood, Thank you so much.

  • @legendsoflife3955
    @legendsoflife3955 2 ปีที่แล้ว +4

    he tried to do little bit good but the main intuition of this approach is missing, I still feel Aditya Verma explained it in a more better way.

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

    Bhaiya you said that if it gets a true in recursion , further recursion will not take place. But we are returning in the end so i think full recursion will take place . Correct me if i am wrong...

  • @cinime
    @cinime 2 ปีที่แล้ว

    Understood! I truly appreciate for your explanation!!!

  • @ritikshandilya7075
    @ritikshandilya7075 22 วันที่ผ่านมา

    Thanks Striver for great solution

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

    i am little bit confused . when and why do we take size = n+1 sometimes while making dp[n+1 ] and sometimes we only take dp[n]

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

      I think, if there is 1 based indexing we take n+1 or else n

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

      @@subhashpabbineedi7136 correct

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

      Did u get your answer ?

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

      @@Codebreaker0702 yes kunal , I take n+1 size everytime, because it works fine most of the time.

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

      in this question you can take n instead of n+1 , it'll work. basically we decide that by looking at the range of indices covered. here it was from 0 to n-1 , hence it covered n indices and hence we declare it as
      vectordp( n , vector(k+1,-1);
      k + 1, because target ranges from 0 to k.

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

    Note that striver changed the color of the curtains behind him from this video onwards.
    Hence from now onwards, all remaining videos of the playlist are very imp

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

    Best DP series so far

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

    Last one was greattt 🔥
    GOAT

  • @parthsalat
    @parthsalat 2 ปีที่แล้ว +6

    Time complexity:
    Recursion: 19:37
    Memoization: 22:20
    Space optimization: 36:44
    Code:
    Recursion: 29:32
    Memoization: 30:52
    Tabulation: 33:15

  • @radekszewczyk3603
    @radekszewczyk3603 2 หลายเดือนก่อน +1

    Understood! Thanks man!

  • @ratinderpalsingh5909
    @ratinderpalsingh5909 2 ปีที่แล้ว

    Understood, sir. Thank you very much.

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

    best explanation.... drawing recursion tree really helps understand better !

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

    Understood. Brilliantly explained.

  • @koushalsharma7041
    @koushalsharma7041 2 ปีที่แล้ว

    Understood! Thank you for the explanation.

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

    Understood !!!! ❤️
    Thank you for this wonderful video

  • @user-pi3yv8hj1v
    @user-pi3yv8hj1v 9 หลายเดือนก่อน

    Very helpful! Thank you very much!

  • @shreyashtech8556
    @shreyashtech8556 3 หลายเดือนก่อน

    bro doing gods work

  • @rapidreplay6062
    @rapidreplay6062 4 หลายเดือนก่อน

    understood Sir .From DP Video 1 I was watching video in that mean time

  • @AngadSingh97
    @AngadSingh97 5 หลายเดือนก่อน

    Thank you Striver bhai..

  • @MukeshKumar-cc3uh
    @MukeshKumar-cc3uh 5 หลายเดือนก่อน

    Sir, you are amazing. Understood. ♥

  • @bahveshjain1730
    @bahveshjain1730 2 ปีที่แล้ว

    understood bhaiya becoz of u i am able to solve dp questions easily now .

  • @Hrushi_2000
    @Hrushi_2000 9 หลายเดือนก่อน

    Understood. Thankyou sir

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

    Understood. Thank you ❤️

  • @rushyya
    @rushyya 9 หลายเดือนก่อน

    UNDERSTOOD! THANK YOUUU

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

    Words of striver matter more than looking screen ❤

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

    Understood and thanks for amazing content you provide

  • @abdallaalhag4425
    @abdallaalhag4425 6 หลายเดือนก่อน

    Did a dry run for the tabulation and space optimization that allowed me to understand the code, with a lil more practice, I will be able to come up with this without the video like how I did with recursion and the memoization solution! Thanks

  • @geetanjalikarma958
    @geetanjalikarma958 9 หลายเดือนก่อน

    Understood!!
    Thank you

  • @Harshit126
    @Harshit126 2 ปีที่แล้ว

    Understood. Thanks for the valuable information.

  • @aps8874
    @aps8874 9 วันที่ผ่านมา

    Thank you so much!

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

    Simply Amazing!!

  • @MohanaKrishnaVH
    @MohanaKrishnaVH 2 ปีที่แล้ว

    Awesome Explanation. Understood!

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

    Understood and Thank You Striver!!

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

    UNDERSTOOD... !
    Thanks striver for the video... :)

  • @gouravmukherjeee6950
    @gouravmukherjeee6950 2 ปีที่แล้ว

    Thank you bhaiya for these wonderful videos ❤️❤️

  • @priyanshuchouhan9845
    @priyanshuchouhan9845 10 หลายเดือนก่อน

    this is the amazing dp journey to me.

  • @shivangpandey9943
    @shivangpandey9943 ปีที่แล้ว +2

    We can use a base case as if(target < 0) return false; this will help us to escape through edge case of bool take call

    • @RoyBoyLab
      @RoyBoyLab 9 หลายเดือนก่อน

      yes

  • @tisalph
    @tisalph 10 หลายเดือนก่อน

    Understood. Superb explanation!

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

    Thank you, understood

  • @coding8000
    @coding8000 2 ปีที่แล้ว

    understood, thank u, sirji.

  • @iamokpara
    @iamokpara 8 หลายเดือนก่อน

    You are awesome. Understood!!

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

    Understood!Thank you very much!

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

    Amazing and understood 🔥

  • @rohit-dd4ww
    @rohit-dd4ww 2 ปีที่แล้ว

    Understood bhaiya... Thanks😊

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

    understood very well❤

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

    Understood. Thank you for this.

  • @vedantgitte784
    @vedantgitte784 9 หลายเดือนก่อน

    Understood, good content

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

    Understood Sir Thank you very much

  • @sukuna905
    @sukuna905 19 วันที่ผ่านมา

    understood sir!!

  • @shaik1525
    @shaik1525 5 หลายเดือนก่อน

    Understood bhaiyya.......

  • @prabhakaran5542
    @prabhakaran5542 4 หลายเดือนก่อน +1

    Understood ❤

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

    understood
    this and the last question were not easy

  • @a_05_himanshu_akula31
    @a_05_himanshu_akula31 10 หลายเดือนก่อน +2

    in tabulation base case we gotta take care of the case where arr[0] > k else dp[0][arr[0]] will go out of bound since dp is set to range of 0 to k

    • @gudlaudaysai4571
      @gudlaudaysai4571 9 หลายเดือนก่อน

      I am about to write this, glad you had asked it and i can confirm that my approach is correct

    • @vishious14
      @vishious14 6 หลายเดือนก่อน

      Quick question. Can you explain why we are marking dp[0][arr[0]] as true.

    • @swapan6785
      @swapan6785 6 หลายเดือนก่อน

      @@vishious14 try doing dry run and you will get it. Basically dp[0] means we are checking only till first element (0th index in arr) and answer would be true only if arr[0] = target, otherwise false.

  • @rahatsshowcase8614
    @rahatsshowcase8614 2 ปีที่แล้ว

    Us ! It was fun to enter into something new!

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

    understood. thank you.

  • @anushilabiswas6947
    @anushilabiswas6947 8 หลายเดือนก่อน

    best vdo ever

  • @jk-sm6qr
    @jk-sm6qr 2 หลายเดือนก่อน

    thanks

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

    Understood Sir, Thank you so much :)

  • @sachinNotOut
    @sachinNotOut 4 หลายเดือนก่อน +1

    you have already explained this in recursion playlist i think and this time you solved this by combination sum problem pattern from that recursion playlist

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

    understood sir
    great explanation