Lecture 111: Combination Sum IV Problem || DP Series

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

КОМЕНТАРІ • 85

  • @riontalukder269
    @riontalukder269 Рік тому +8

    those who are facing run time error with the tabuation method in leetcode, please try to assign the vector dp. It will help in dealing integer overflow.

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

      yes it happened with me.

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

      also what if i-nums[j] becomes > target. we are only checking the lower bound of index. why are we not the checking the case when index may become grater than the size of dp array

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

      it cant be greater than the target as the nums array is always greater than zero so i - nums[j] is always less than the target
      @@taneyasoni

  • @harshgarg1089
    @harshgarg1089 2 роки тому +16

    Time Complexity is actually O(target * nums.size) and not O(target) .

  • @harshmehta1282
    @harshmehta1282 2 роки тому +7

    4:50
    Le machhar: I am the first one in my species who is friends with a human.

  • @shreyashdubey5989
    @shreyashdubey5989 2 роки тому +5

    Thank you Bhaiya, Just keep going... More strength to you . This is helping us a lot✨✨✨✨

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

    very good explanation bhaiya ,tablulation wala abhi acha seh visualise hua..

  • @shachisinghal8856
    @shachisinghal8856 11 місяців тому +1

    Sir pls also show dry run of tabulation code ...🙏🙏

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

    Tabulation is not optimised than Memoisation in this Question bcz tabulation's Time Complaxity is O(n*m)

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

    what if I want to print those ways, like in a list of list containing all the combinations
    Like {{1,1,1,1,1},{1,2,2},{2,3},{1,1,3},{1,1,1,2}}
    can we apply dp in that case, because as I observed many problems of dp covers "number of ways" or "count"

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

    Day 4 of DP | Completed

  • @dheerajn1234
    @dheerajn1234 2 роки тому +4

    Bhaiya leetcode premium giveaway abi tak ni hua 😒😒

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

    Named as perfect sum in GFG 👍🏻👍🏻 you can search it and solve it.

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

    accha h accha h bahut acchaaaaaa. .. h :-)

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

    Awesome explanation again. Keep posting videos.

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

    I think there should a 4th step when using memoization...that is pass the dp array to recursive call so that we don't forget this.

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

    Bhaiya ,, abhi kitna lectures aur baaki hai ??

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

    started the course a month back, now on video 54th!

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

    Hello love, recently I got question in one of my interview to check if circular linked list is sorted in ascending order or descending and find head can you help

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

    sir 8:12 yaha par ans=1+solve() kyu nai kiya ans=ans+solve() kyu kiya

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

    7:05

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

    How many videos left in this series ?

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

    Bhaiya dhud ka dhud or Pani ka Pani ho gya 💘 se

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

    Bhai koi esa video banao jisme complete ROADMAP ho ARTS background ke STUDENTS KE LIYE

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

    Koi development mai course laane ka plan hai kya bhaiya.....???

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

    Series going awesome ☺️☺️

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

    can we solve this using the include exclude method

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

      by applying for loop for each target we are already excluding previous ith element from num after i++

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

    Bhaiya is series me kitte videos honge??

    • @011_aniketkumar3
      @011_aniketkumar3 2 роки тому

      total 65 videos
      including easy medium & hard quesions

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

    I have a doubt, should time complexity of Recursion + Memoization solution be O(tar*n), where n is size of num array, as for every num, we are checking if target was met recursively....

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

    Great explaination

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

    If we want to print the all array from which we got the target so what is the approach

  • @AnkitSharma-hc3xh
    @AnkitSharma-hc3xh 2 роки тому

    gr8 bhaiya

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

    yahan base case 0 rakhun , aur recusrion ke answer + 1 storre krun to usme kya galat hai?

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

    Maja aaya

  • @03_abhishekchoubey42
    @03_abhishekchoubey42 2 роки тому

    Bhiya pata kese chalega ki base case reach hone pr
    Kab 0 return karna hai kab -infinity return karna hai
    Ya kab INT_MAX return karna hota hai
    Love from indore bhiya❣️

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

    thank you bhaiya

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

    Bhaiya Online Assesment(For Faang) ke liye ek dedicated video chahiye with some resources please bana dijiye..

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

    amazing

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

    awesome

  • @dinobandhuchakraborty5202
    @dinobandhuchakraborty5202 Рік тому +1

    Tabulation method katai nhi samjh aa rha

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

    why are we making dp of size target+1?

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

    completed

  • @Ddot-cd1in
    @Ddot-cd1in 2 роки тому

    Sir kitne or video aayenge c++ series ke

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

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

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

    First time attend DP lecture I like it but plz ap. Thoda slow Bologe it will easy to. Understand

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

      playback speed kam karle bhai , itna stress kyu lera h.

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

      @@mikelan9854 are wo jo bolte hai wo bohot fast hai

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

    can we do it using 2 D dp instead of for loop ?

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

    Thanks sir

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

    Bhaiya dp ka size n+1 q use Kiya h n nhi hoga?🤔

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

    Java LeetCode Solution:
    class Solution {
    public int combinationSum4(int[] nums, int target) {
    //1D dp bcz only 1 para changing
    int[] dp=new int[target+1];
    Arrays.fill(dp,-1);
    return helper(nums,target,dp);
    }
    private int helper(int[] nums, int target,int[] dp){
    if(target==0) return 1;
    if(target

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

    why we took target+1 as the size of the dp array.

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

      Because you want to return an element at index "tar", for that you need a space of "tar +1"

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

    First🔥🔥

  • @Sandeep-gl1by
    @Sandeep-gl1by 2 роки тому +1

    🔥🔥🙏🙏

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

    Done

  • @saravana5891
    @saravana5891 9 місяців тому

    Since both the index and sum are varying why isn't it a 2D DP concept

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

      because the reduction is happening only in tar

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

    Reach++

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

    ✔✔✔✔

  • @manoj.siddharthnagar
    @manoj.siddharthnagar 2 роки тому

    🙏🙏

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

    Bro oops in Java ka banao vedios

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

    understand++

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

    Present bhaiya

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

    swad++

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

    a

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

    f

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

    t

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

    e

  • @KhushiKavya-py1yj
    @KhushiKavya-py1yj 4 місяці тому

    1/10 consistency++

  • @AdityaRaj-fp1jo
    @AdityaRaj-fp1jo 2 роки тому

    Recursion + memoization code , Beginners friendly. hope it helps.
    class Solution {

    int dp[201][1001];
    int f(int i, int k , vector & nums){
    if( i == nums.size()) return(k ==0);
    if(dp[i][k]!= -1 ) return dp[i][k];
    int p =0;
    int np = f(i+1 ,k,nums);
    if(k>=nums[i])
    p=f(0,k-nums[i],nums);
    return dp[i][k] = p + np;
    }
    public:
    int combinationSum4(vector& nums, int target) {

    memset(dp,-1,sizeof(dp));
    return f(0,target , nums);
    }
    };

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

    Koi development mai course laane ka plan hai kya bhaiya.....???

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

    Koi development mai course laane ka plan hai kya bhaiya.....???

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

    Amazing