Longest Increasing Subsequence (Dynamic Programming)

Поділитися
Вставка
  • Опубліковано 5 жов 2024
  • Find longest increasing subsequence using dynamic programming.

КОМЕНТАРІ • 122

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

    thank you bro
    after watching 5 videos related to LIS
    i came here and get a clear explanation thank you so much

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

    I like your style, your explanations are much clearer than others'. Thanks!

  • @zannatprome5587
    @zannatprome5587 4 роки тому +4

    Finally i found a proper explaination. Thanks 💖

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

    Hats off of your videos! Clearly and neatly explained. Good job Vivek

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

    Excellent explanation!! Thanks for making it easier to understand and making a complete video.

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

    You are really great!! Thank you so much. No more words to express...You explained it the best way possible

  • @rahulkumargupta9565
    @rahulkumargupta9565 5 років тому +2

    sir i had watched more than 10 videos and read many blogs but i didnt understand...but now i understood :)

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

    Thank you very much .
    i did not understand in the class but you are the who help me to feel happy
    i appreciate your effort

  • @ahmedabdelaziz5383
    @ahmedabdelaziz5383 6 років тому +10

    Yo are amazing! I can`t find any vedio explain the increasing sequence in such details like you. Just try to add a code and you will be the best among others :)

  • @Lisa224224
    @Lisa224224 7 місяців тому +2

    thank you so much! it was an excellent explanaition!

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

    WOW, you gave the best explanation for LIS. All your lectures are super! Thanks lots!

  • @mohammedsuhailbasha4860
    @mohammedsuhailbasha4860 5 років тому +1

    Very beautiful explaination.thank you so much

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

    Thanks Vivek for detail explanation. There is BST method (patience sort)to do same in O(n log n) time complexity. Kindly add that also.

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

    WONDERFUL explanation sir !
    This video helped me a lot👍

  • @jeyavanicm1224
    @jeyavanicm1224 4 роки тому

    ur way of teaching is too easy to understand. Thank you , so much!

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

    you actually teaches very well thanks for this video

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

    Amazing best explanation i have seen so far.

  • @MiralkumarPatel
    @MiralkumarPatel 4 роки тому +3

    Very thorough explanation. Pro tip: Watch at 1.5x speed :)

  • @Dima-rj7bv
    @Dima-rj7bv 4 роки тому +2

    The best explanation I found so far!

  • @aishwaryasingh246
    @aishwaryasingh246 5 років тому +1

    Thank you so much! Really appreciate your effort in explaining the algorithms in such depth. :)
    I usually watch your videos for the algorithms and it has helped me a lot.

  • @davidkreft9843
    @davidkreft9843 5 років тому +1

    Awesome video! All explained very carefully and clearly.

  • @deveshpathak7538
    @deveshpathak7538 6 років тому +27

    Your videos are great but include the code too if possible

    • @qc4257
      @qc4257 4 роки тому +1

      write your own code!

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

    excellent explanantion and hatsoof for ur tireless efforts ..worthy video compared to all other on this topic..keep continuing sir

  • @ravibeli
    @ravibeli 6 років тому +1

    Awesome Bhai.... You are great explaination... Many video I saw, but I understood this logic after watching your more iteration's example. :) Keep it up I do not need code, I can write as logic is understood.

  • @SmartProgramming
    @SmartProgramming 6 років тому

    awesome explanation sir, keep it up, thank you 👍👍👍👍🙂🙂

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

    Thank you very much! So well explained.

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

    one stop solution :) great way of teaching sir . thanks ❤

  • @leereid2915
    @leereid2915 8 місяців тому +1

    Lots of thanks for your explanation. I did the code according it:
    public int lengthOfLIS(int[] nums) {
    int n = nums.length;
    int[] l = new int[n];
    int[] idx = new int[n];
    int max = 1;
    for (int i = 0; i < n; i++){
    l[i]=1;
    int j = 0;
    while(j < i){
    if (nums[i]>nums[j]){
    int temp = l[j]+1;
    if (temp >= l[i]){
    l[i]=temp;
    idx[i]=j;
    }
    }
    j++;
    }
    max = Math.max(max, l[i]);
    }
    return max;
    }

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

    awesome explanation, May God bless u sir :)

  • @cherrynamburu2860
    @cherrynamburu2860 6 років тому +2

    Awsome expaination...you are the Best..! it would be helpful if the code is included

  • @ly4422
    @ly4422 4 роки тому +1

    Thank You So Much! This video was super helpful!

  • @andreiardelean5712
    @andreiardelean5712 5 років тому +1

    m-ai salvat de o restanta, mersi fain coaiemiu, ai o bere!!!

  • @ganeshkumarmiriyala3607
    @ganeshkumarmiriyala3607 4 роки тому +1

    Thank you for the clear explanation!

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

    Amazing!!! searched through many but this video is the one :)

  • @hullopes
    @hullopes 4 роки тому

    Hello. Your video was very helpful. Just for about the creation of the sequence was not quite clear for me. Thanks.

  • @radkan1440
    @radkan1440 4 роки тому

    Really good and clear explanation

  • @ShivangiSingh-wc3gk
    @ShivangiSingh-wc3gk 5 років тому +3

    Please can you make a video on O(nlogn) algorithm that can be used to solve this.

  • @prakashkapoor
    @prakashkapoor 6 років тому

    Thanks a lot, sir your videos are very good. One suggestion it will very helpful if you can put videos in the playlist in a sequence.

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

    Excellent Explanation!!

  • @shashankprashar1724
    @shashankprashar1724 6 років тому +2

    hello sir ....can you explain the recursive approach for the same problem ..i refered every site on internet but could not understand how the recursive solution is working...every body is just explaining the DP approach.

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

    Thank you ...best explanation...

  • @findarpit92
    @findarpit92 4 роки тому

    Your explanation are best . But please try to include some sort of psedo code.

  • @sahulrajhansa8363
    @sahulrajhansa8363 6 років тому +1

    I think we can simply use a length variable instead of length array and assign the maximum value to the length variable in the outer Loop

    • @ranesh237
      @ranesh237 6 років тому

      No we cant. Because we need to store the length of the longest increasing subsequence up to each of the indexes. So we need the length array.

    • @ranesh237
      @ranesh237 6 років тому +1

      However we can have a maxLength variable to store max length at each iteration so we don't have to iterate through the array a second time to find the max length.

  • @vikramchaudhary440
    @vikramchaudhary440 6 років тому +1

    Thank you for such a nice video. But the algorithm is very time consuming with the time complexity of O(n^2). Could you please provide a better solution.

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

    you dont even need a result array, you can keep two variables called maximum_seen_so_far, and length_of_subsequence, and as you iterate the loop, just update the two variables. That way the space complexity is O(1). Its still O(n^2) though. I suppose doing a binary search on a tree will make it O(h)? where h is height of the tree?

  • @arpitverma8060
    @arpitverma8060 4 роки тому +1

    Great work!!! Appreciated

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

    best explanation ever !

  • @pranjalimpatil820
    @pranjalimpatil820 4 роки тому

    thank u so much sir.Could you please make a video on digit dp

  • @vishalmahavratayajula9658
    @vishalmahavratayajula9658 4 роки тому +1

    This is O(n^2). Please explain O(nlogn) solution with patience sorting

  • @SL-sf7oh
    @SL-sf7oh 4 роки тому

    Thanks Sir ! Learn a lot

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

    Bruh, I can search for how to make apple pie or how to solve leetcode questions and bam, an Indian pops up with an explanation.

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

    I think it would be nice if you explain why the index array behaves like you described, i.e., going backward works and discovers longest increasing array.

  • @thesoftwareengineer17
    @thesoftwareengineer17 4 роки тому

    Hey Vivek it would be helpful if u can add the code snippet

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

    thanks a lot bro... keep it up!!!
    but how to compute time complexity of this algorithm

  • @deivakumarand5548
    @deivakumarand5548 6 років тому +2

    Please do video on Flattening a Linked List

    • @sinharakshit
      @sinharakshit 6 років тому +1

      LinkedList is already a flat data structure.

  • @riyastk1
    @riyastk1 4 роки тому

    In the subseq array, what will be the previous element if there is no matching element at all. Ex: there is a 0 at 4th index a d there is no smallest elements for any j.

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

    awesome sir

  • @andre-codes
    @andre-codes 3 роки тому

    Very well done, thank you.

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

    class Solution {
    public:
    unordered_map mp;
    int solve(vector nums, int last, int index){
    if(index == -1) return 0;
    if(mp.count(index)) return mp[index];
    if(nums[index] < last)
    mp[index] = max(1 + solve(nums, nums[index], index - 1), solve(nums, last, index - 1));
    return solve(nums, last, index - 1);
    }
    int lengthOfLIS(vector& nums) {
    solve(nums, INT_MAX, nums.size() - 1);
    return mp[nums.size() - 1];
    }
    };
    Please debug this code, when I don't use DP this solution works when I store in DP array it don't work

  • @sumanasriudumula6817
    @sumanasriudumula6817 6 років тому

    Please do vedios on
    Deletion of a node from AVL tree. And RedBlackTrees concept

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

    Thank you so much!

  • @AbdulBasith-vn8bs
    @AbdulBasith-vn8bs Рік тому

    Sir could u plz explainthe C code how AVL tree insertion deletion happen

  • @rajitgupta6258
    @rajitgupta6258 4 роки тому

    sir cant we just sort the array and then find longest common subsequence ???

  • @leonardofernandezrios7130
    @leonardofernandezrios7130 4 роки тому

    Topological sort in a DAG, please.

  • @deviduttshanbhogue879
    @deviduttshanbhogue879 6 років тому

    Awesome logic!! Gr8 video.. tysm

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

    i am watching this x2 speed.Can't understand what he is saying,but i understand the writings

  • @shubhamsunny6024
    @shubhamsunny6024 6 років тому +2

    can you make a video on XOR linked list,please?

  • @sopantalekar2529
    @sopantalekar2529 6 років тому

    really very good teach....

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

    Code for the above Algorithm
    in case you couldn't manage to write it by your self
    void solve(int arr[], int n){

    int lis[n];
    int inde[n]; // one array will require to find the length of longest increasing subsequence
    lis[0]=1;
    for(int i=1;i

  • @rezamonang
    @rezamonang 5 років тому

    ty for your explanation sir

  • @theanikaanisha4414
    @theanikaanisha4414 5 років тому

    Can you please cover Length of Longest Fibonacci Subsequence problem?

  • @ranjanaashish
    @ranjanaashish 6 років тому +1

    Very helpful. Thanks :)

  • @dmxrahul
    @dmxrahul 6 років тому

    Nice video! Well explained.

  • @BaishaliGhosh13
    @BaishaliGhosh13 6 років тому

    Nice explanation.

  • @saravanasiva6476
    @saravanasiva6476 4 роки тому

    Sir first off all how to choose the sequence plz tell me

  • @lakshmibhavani5560
    @lakshmibhavani5560 4 роки тому

    Thank you sir

  • @thachnguyen409
    @thachnguyen409 4 роки тому

    Great, thank you.

  • @programmingstuff4031
    @programmingstuff4031 6 років тому

    nice explanation ...

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

    still the best explanation

  • @williamwambua7710
    @williamwambua7710 4 роки тому

    Hello!!! Where did this guy go to?

  • @עדירגב-ל3ת
    @עדירגב-ל3ת 4 роки тому

    where can i get exactly written code like this?

  • @anushkadeshpande8754
    @anushkadeshpande8754 4 роки тому

    can you explain with code

  • @sriram.r_
    @sriram.r_ 5 років тому

    thank u so much sir...

  • @vivekraj9875
    @vivekraj9875 5 років тому

    You're awesome 👌👌♥️

  • @ayaan-world
    @ayaan-world 5 років тому

    thank you so much

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

    You are amazing

  • @daanishsarguru3044
    @daanishsarguru3044 5 років тому

    Thank You

  • @h.a1625
    @h.a1625 10 місяців тому +1

    🔥🔥🔥🔥🔥

  • @saisrikar7987
    @saisrikar7987 6 років тому

    sir, y aren't you making videos nowadays..?

  • @shrad6611
    @shrad6611 5 років тому

    Pseudo Code
    /* lis() returns the length of the longest increasing
    subsequence in arr[ ] of size n */
    int lis( int arr[], int n )
    {
    int lis[n]
    lis[0] = 1
    /* Compute optimized LIS values in bottom up manner */
    for (int i = 1; i < n; i++ )
    {
    lis[i] = 1;
    for (int j = 0; j < i; j++ )
    if ( arr[i] > arr[j] && lis[i] < lis[j] + 1)
    lis[i] = lis[j] + 1
    }
    // Return maximum value in lis[]
    return *max_element(lis, lis+n)
    }

  • @amitrawat2915
    @amitrawat2915 5 років тому

    Thankyou so much ✌

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

    0,2,6,9,11,15 is the correct answer

  • @tanveerhasan875
    @tanveerhasan875 6 років тому

    so helpful .

  • @lucasalexandre1301
    @lucasalexandre1301 5 років тому

    Basile?

  • @nguyenminhtam2302
    @nguyenminhtam2302 6 років тому

    I don't know why my output is 15 13 9 6 4 0, somebody help

  • @srilekha9177
    @srilekha9177 5 років тому

    what is the time complexity of this algorithm?

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

    Thanks ;)

  • @hrishikeshdadhich2821
    @hrishikeshdadhich2821 6 років тому

    Multi threading red black tree please

  • @jayeshborgaonkar9166
    @jayeshborgaonkar9166 5 років тому

    very nice

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

    Try to recite little fast