Longest Increasing Subsequence

Поділитися
Вставка
  • Опубліковано 1 жов 2024
  • Given an array find longest increasing subsequence in this array.
    / tusharroy25
    github.com/mis...
    github.com/mis...

КОМЕНТАРІ • 282

  • @atishnarlawar1177
    @atishnarlawar1177 6 років тому +41

    Its worth to appreciate the hard work. Any one can easily see him so exhausted after doing the daytime job at Apple. But he still makes these helpful videos. Kudos!

  • @anamigator
    @anamigator 7 років тому +106

    Intuition behind this solution:
    If the current element is greater than the previous element, we can safely add 1 to the value of previous max sum. Since the previous max sum was also calculated in a similar manner (optimal substructure) we can safely add 1 to previous max value to get the current value.
    If you notice in case of 6, since it is greater than 0, you can add 1 to the max value at 0. But there is a catch, you can have previous elements (for example 4) which can give you a bigger subsequence. Hence to check this, every time the "j" begins with zero. Or you can even start at the given i and keep going backwards with a j variable to check if there are two or more contending elements which can give you the max value.
    Notice how we construct the solution from using the previous solutions (previous values in array). This is in essence Dynamic Programming where you remember the previous computed values and make calculations faster.
    PS: please correct mistakes if any.

  • @Autom_te
    @Autom_te 4 роки тому +31

    This example was so clear and easy to follow that I can only wonder _how_ my professor did such a bad job at explaining this. Thank you!

  • @karthikmucheli7930
    @karthikmucheli7930 5 років тому +51

    yes, we will have to use DP to solve this problem. :D:P

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

      XD

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

      staaahpp!!! 😂

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

      Actually a better solution is to use binary search, the time complexity becomes N logN, but its good to know DP

  • @abnormal7273
    @abnormal7273 8 років тому +245

    @Tushar: Just a suggestion, it would be great if you can solve it using recursion first and then explain as how this problem falls into DP category.

    • @soumavanag5025
      @soumavanag5025 7 років тому +7

      u are right

    • @generalroboskel
      @generalroboskel 7 років тому +16

      I agree that explaining the recursive or iterative brute force method first would be better. Doing so would help with making the connection from how you would solve the problem naively, to how you could use dynamic programming to solve it faster

    • @arfathali6669
      @arfathali6669 5 років тому +4

      I dint find one video or good article, explaining recursion solution :(

    • @kanhar
      @kanhar 5 років тому +10

      This is the recursive solution
      def li_seq(arr):
      if not arr:
      return 0
      if len(arr) == 1:
      return 1
      count = 0
      for i in range(1,len(arr)):
      end_at_i = li_seq(arr[:i])
      if arr[-1] > arr[i - 1]:
      count = max(end_at_i + 1, count)
      return count

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

      he wont do this cuz solving this problem by recursion it would take too much, just imagine that if u give a super long subseqvence it can take up to some months for your computer to find the solution, the best 1

  • @mystikcoder144
    @mystikcoder144 5 років тому +10

    Really really great explanations, thank you very much. Just one suggestion : I thoroughly understood the solution but still I don't know the intuition behind coming up with this solution. Could you please explain that also? Oh And the time complexities as well. thanks again :) :)

    • @venkateshdec27
      @venkateshdec27 3 роки тому +5

      The intuition here is like an eye ball movement. Let's say you have a simple array [1,2,4]. The answer is 3. How ? In the eyeball movement you see the number 1 then register in your brain 1 . When you go to the next number 2, your brain takes the previous value from your brain which is 1 and add 1 more to it and store it back to 2 in your brain. Same thing when you move your eye to 4. Take the previous value from your brain which is 2 and add +1 which is the final answer (3). Here we lay down our brain as one dimension array. The default value is 1 that mean if you select any number randomly the answer is 1. E.g. [12,4]. If I choose 12 from my eye ball it is 1 or if I choose 4 also the default value is 1. The process of incrementing 1 from previous array value is same as reading the existing brain content and add 1. This is the thumb rule of knapsack problem. You keep updating your brain with the best increasing value by erasing the old content and update the new content. Same here we do select the maximum value of the current value or the previous value +1. Eventually any DP tabulation problem is just converting the eyeball movement calculation into array layout. Hope this helps you. Thank you!!!

  • @souvikghosh5668
    @souvikghosh5668 2 роки тому +6

    He is such a gem of a person. I don't know why he has stopped making such videos now. Wish he comes back again.

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

    This video is made 6 years ago and still one of the best

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

      Yes..I'm having 3rd semester now😄😨

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

      yea it so crazy. 8 years later, I watched like 10 newer videos yet this is still the best explanation.

  • @weijiang252
    @weijiang252 7 років тому +14

    Thanks for your sharing ! If only I had seen it earlier 😭!

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

    There is a small optimization here (Not talking about DP):-
    Rather than starting j from index 0, start j from i-1 and then go backward. what difference will it make? see below:
    If let's say you're at index i = 500 Then you move from j=499 and at j=300 you find that its LIS is 200 and array[j] is lesser than array[i], then you make LIS of i=500 as 200+1 = 201. Now when you continue going backward i.e j=299,298,297.......then you do not need to go beyond j=200 because you already know that those elements can have LIS as 200 at max, So no need to compare.... This would save your 200 iterations which you had to do when you were starting j from 0 index.

  • @HARSHALPRIYADARSHI
    @HARSHALPRIYADARSHI 9 років тому +5

    Additional fact: To backtrack all you need to do is to maintain a separate array of size N, which stores the "j" for which the "i"th index was last updated. Then when you get the maxima in the original array, just search for the index of j recursively, until you reach a number which has the value of 1 in the original array

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

    this is the O(n^2) solution but in GFG is it mentioned to solve in O(nlogn).

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

    Maybe I am wrong but can you guys clear me one thing ,
    We call a solution solved through DP when we solved the problem by dividing the main problem and then solving the sub-problem (divide and conquer) and because those sub-problems are overlapping that's why we apply memorization technique to store the overlapping subproblem.
    The problem here is that if I ask u the LIS for the first 3 index then it should be 2 there but it is stored 1 here ,
    in any dp soln the intermediate values are also the solution of some sub problem
    This question do contain the memorization technique but I don't think the solution really is a DP.

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

    Great video! I wrote a function in Python that implements the algorithm Tushar exposed in the video.
    Hopefully this helps someone better understand how it works...
    def LIS(arr):
    j, i, t = 0, 1, [1] * len(arr) # initialize ints j, i and array t
    while i < len(arr): # loop while i is within the sequence's bounds
    if arr[j] < arr[i]: t[i] = max(t[i], t[j] + 1) # exact same logic Tushar wrote at the end of video
    j = j + 1 # at each iteration, increment j
    if j == i: j, i = 0, i + 1 # if j meets i, set j to 0 and increment i
    return max(t)

  • @Profnegi
    @Profnegi 2 місяці тому

    bro thx a lot.. most of the youtuber now a days just focus on learning the dp and do recursive solution then convert into dp (tabulation) just follow the prewritten steps by some youtuber.. they don't understand, how amazing the tabulation is..

  • @alfonsovalenciana436
    @alfonsovalenciana436 Рік тому +2

    After all these years, I still come back to this channel. Always loved the clear way you explain!

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

    For people who don't have much time to watch the entire video here is the solution
    0:45 --> "Yes we will have to use dynamic programming to solve this "

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

    This is the code from your github
    public int longestSubsequenceRecursive(int arr[]){
    int maxLen = 0;
    for(int i=0; i < arr.length-1; i++){
    int len = longestSubsequenceRecursive(arr,i+1,arr[i]);
    if(len > maxLen){
    maxLen = len;
    }
    }
    return maxLen + 1;
    }
    I think, the below code is sufficient. You are unnecessarily looping I think. Please clarify.
    public int longestSubsequenceRecursive(int arr[]){
    return longestSubsequenceRecursive(arr, 0,Integer.MIN_VALUE);
    }

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

    Im out of words, i couldn't find a solution to this problem on my own

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

    #include
    using namespace std;
    int main(){
    int array[]={6,2,5,1,7,4,8,3};
    int n=8;
    int lenght[8]={1,1,1,1,1,1,1,1};
    for(int k=0;k

  • @abhishekgorisaria2897
    @abhishekgorisaria2897 9 років тому +8

    All your videos are excellent, extremely Helpful.

  • @VikasGupta2014
    @VikasGupta2014 8 років тому +1

    I have one suggestion. Before solving any DP problem, please first solve it with recursion then only move to DP. This will help us in better understanding of the problem and why is the need of DP here.

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

    Thank you, algoexpert explained it in 1 hour and it was still not clear as yours!! Cheers thnx👍

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

      lmao never buy algorithm courses

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

      just use geeksforgeeks or hackerrank, its wayy better and covers more stuff. Maybe not systems interview stuff but still

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

    For recreation this is a fun video BUT if you wanna look at this from algorithmic point of view this is trash. And please use RECURSION

  • @igeolasoji3513
    @igeolasoji3513 11 місяців тому

    n(3n)
    public static int lengthOfLIS2(int[] nums) {
    int[] dp = new int[nums.length];
    int max = 0;
    int totalJIterations = 0;
    for (int i = 1; i < nums.length; i++) {
    for (int j = 0; j < i; j++) {
    totalJIterations++;
    if ((nums[j] < nums[i]) && ((1 + dp[j]) > dp[i])) {
    dp[i] = 1 + dp[i];
    }
    max = Math.max(max, dp[i]);
    }
    }
    // n(3n)
    // System.out.println(Arrays.toString(dp));
    System.out.println("TotalJIterations: "+ totalJIterations);
    System.out.println("Num size: "+ nums.length);
    return max + 1;
    }

  • @msylvest55
    @msylvest55 9 років тому +10

    Tushar, you are the shit. Couldn't get through DP w/o you.

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

    what if the last number in the array is the smallest number? then you would do nothing since arr[i] > arr[j] is false, so the answer just becomes 1?

  • @prshnt006
    @prshnt006 9 років тому +4

    at 02:42, why would the value at -1 be 1 ? shouldn't it be 2 ? because the value represents the length of the LIS up until that point. so up until -1, LIS would be of length 2 containing 3 and 4.

    • @xiaomingchen7543
      @xiaomingchen7543 8 років тому

      same question ... Anyone can explain why?

    • @wpp6986
      @wpp6986 7 років тому +3

      It represents the longest increasing subsequence up until that point including the value in question. It's necessary because when you do the comparison later, you need to know the maximum value up to that point. If we set the value at -1 to 2, then a later 0 or 1 would give us a subsequence of 3, which isn't actually true because the full subsequence doesn't contain a -1. For example, if you walk through the algorithm like you described, we would have a longest subsequence value of 3 at value 0, and 4 at value 6.

    • @zhengmouduan9565
      @zhengmouduan9565 7 років тому

      the index below shows `the LIS about the current number`, instead of `globally longest`, i.e. let's consider the number `6`, we have LIS: 3,4,6, when we check the 3, we add 1 to index of 6, when we check the 4, add 1 again, this process means that `we found at most 3 lengths increasing seq including 6 itself, after we launch this process for all the number, we can find the longest seq by checking the length index

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

      It represents Length of subsequence using elements till that index and *including* that element in the subsequence.
      So if we include -1 in subsequence, we get {-1} as subsequence.

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

    watched it and tried casually. Here is my working answer. For both of these cases, its working.
    const arr = [3,4,-1,0,6,2,3]
    const arr1 = [1, 1, 1, 1, 1,1,1]
    let j = 0
    let i = j + 1
    while (j < arr.length) {
    while (i < arr.length) {
    if (arr[j] < arr[i]) {
    // arr1[i]=arr1[j]+1
    arr1[i] = Math.max(arr1[j] + 1, arr1[i])
    j++
    console.log("first", arr1);
    } else {
    j++
    console.log("second");
    }
    if (j === i) {
    j = 0
    i++
    console.log("third");
    }
    }
    break
    }

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

    How is this solution any better than a stack based solution ie maintain stack for every element and check for max length? The time would be n^2 space would be n and as a plus point we can even get the elements?

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

    great sir, the way you have explained is awesome, keep it up sir 🙂🙂👍👍👍👍

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

    in 3rd location value is (-1), where u r telling maxLength is 1, but it should be 2. Please verify

  • @jatinpathangi486
    @jatinpathangi486 8 років тому +44

    Wouldn't your solution be O(n^2)?

    • @NovaMenteMedia
      @NovaMenteMedia 7 років тому +5

      It is , he explains a O(n log n) in another video

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

      Could you tell me which video for O(n log n) ? Thanks!

    • @sarthakgupta072
      @sarthakgupta072 6 років тому +5

      ua-cam.com/video/S9oUiVYEq7E/v-deo.html

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

      yes

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

      Bhai DP laga le ab to ...concept to samajh aa hi gya na

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

    thank you for this video this helped me in my upper div Data Structures class in university for a quiz.

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

    The recursive approach according to me:-
    1. Iterate through the array containing the sequence.
    2. We will have two options either we can select the first element or not.
    3. Now if the next element of the array is greater than the previous element we will again have two choices either we can select the element or not.

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

      no because its not guarenteed that next element itself would contribute to the ans

  • @vikremsheker
    @vikremsheker Місяць тому

    Excellent explanation ! Thank you for taking the time to make these videos !

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

    Thanks still helpfull

  • @SubhamKumar-eg1pw
    @SubhamKumar-eg1pw 8 років тому +1

    Struggled whole day on a problem on alternating sequence. Then solved within 15 minutes after watching this. Thanks a lot :)

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

    Thanks Brother!!..Very Nice and clear explanation!!

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

    thank you sir

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

    its pretty much finding the number of elements which are less than a certain index...

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

    What if the last element is -3? Then answer would be 1 instead of 4!

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

    Excellent videos!Great going..I haven't seen such wonderful videos with clear explanation.Only through your videos i came to know clearly what dynamic programming actually means. Still that i couldn't understand anything just i thought we need to build a 2D array by your video only i came t know how the principles of dynamic programming are satisfied.Keep posting videos.

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

    definition of subsequence is confusing - leetcode.com/problems/longest-continuous-increasing-subsequence/

  • @gsman1880
    @gsman1880 7 років тому +3

    굿 깔끔한 설명

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

    Theres a bug in the code, it doesnt pass a particular test case in leetcode.
    [1,6,4,2,7,5,34,8,6,34,45,7,4,2,75,3,55,7657,6547,345,3254,12364,4435,4]

  • @victormillan2965
    @victormillan2965 9 років тому +3

    What it is the best, worst and average case?

  • @katic512
    @katic512 7 років тому +3

    seems like this is O(n^2) complexity, isn't this costly, aren't there any better solutions ?

    • @eldan_nomad
      @eldan_nomad 7 років тому +2

      You can use binary search for optimized this problem;
      int d[MAXN];
      d[0] = -INF;
      for (int i=1; i

    • @amroibrahim5746
      @amroibrahim5746 7 років тому +1

      how can u use binary search when the data is not sorted? can u provide a full working code?

    • @eldan_nomad
      @eldan_nomad 7 років тому +1

      ideone.com/5L3zHE

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

      O(nm) not O(n^2)

  • @offchan
    @offchan 8 років тому

    I like that you put the word Length at the end of LIS. It is stating that you completely understand it. Finding the length instead of the actual LIS itself was confusing me a lot!

  • @ytuser659
    @ytuser659 9 років тому +1

    after finding the length, how do we get the elements in the sequence?

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

    what shall be done to extract the sequence of max length ?

  • @gurbraj
    @gurbraj 7 років тому

    Why is the answer 1 for subproblem 2 (with subarray [3,4,-1])? I would have thought 2, since {3,4} can be formed....

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

    how easily you explain complex things in a snap.

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

    *Best & shortest implementation in CPP using std*
    int lengthOfLIS(vector& a)
    {
    int i,ind,n=a.size();
    vector v;
    v.push_back(a[0]);
    for(i=1;iv.back()) v.push_back(a[i]);
    else
    {
    ind=lower_bound(v.begin(),v.end(),a[i])-v.begin();
    v[ind]=a[i];
    }
    }
    return v.size();

  • @jmpokar
    @jmpokar 9 років тому

    Nicely Explained. Like it very much. In any of your videos, is it explained with O(N Logn N) complexity?

  • @slowmotion2300
    @slowmotion2300 2 місяці тому

    No fancy animation, no BS music and intros, 100% explanation, You make it look like it's a piece of cake.

  • @mukeshjeengar140
    @mukeshjeengar140 8 років тому

    Program in python of this video:
    t = int(raw_input())
    while t!=0:
    n = int(raw_input())
    a = list(map(int,(raw_input()).split(" ")))
    v = list()
    for i in range(n):
    v.append(1)
    for i in range(1, n):
    for j in range(0, i):
    #print j, i, a[j], a[i], v[i], v[j]+1
    if a[j]

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

    trying to solve for last 30 min, but couldn't do it. And after seeing such simple explanation i am totally broken.

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

    The of explaining is owsm ❤️

  • @jaideepbommidi8611
    @jaideepbommidi8611 8 років тому

    i have doubt to handle large numbers do we need to learn java or python.
    since in c and c++ we are unable to solve.
    we are able to write code but it is unale to process such large data.
    as i heard only java and python can handle such large data, but c,c++ can't

  • @jaideepbommidi8611
    @jaideepbommidi8611 8 років тому

    1000000, if input is this long will it not give "terminated due to run out" message in java.
    Thanking you very much

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

    Wow, that’s the first video on that subject there I finally understand the algorithm! Many thanks!:)

  • @KanagaveluSugumar
    @KanagaveluSugumar 8 років тому

    Nice, but is it possible to get the subsequence also ?? Since you gave that option in "Longest Common Subsequence" video :)

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

    great video, thank you!

  • @NasifAhmed002
    @NasifAhmed002 9 років тому

    What is the time comoplexity of this algorithm?

  • @surendrapalSingh
    @surendrapalSingh 7 років тому

    @Tushar...I went through you code and I finding it hard to understand the 'print the actual solution' part of it wherein you want to print the LIS. Please help.

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

    nlgn solution : ua-cam.com/video/Rf0Mod_uQKw/v-deo.html

  • @nadeembhati4381
    @nadeembhati4381 9 років тому

    There is O(nlogn) way to get LIS. can u explian that one or provide links for the solution ?

  • @rohitparkhe689
    @rohitparkhe689 2 місяці тому

    This video is the definition of precise.

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

    @Tushar You are awesome man , dp was a real pain for me, after seeing your videos, I am so comfortable, keep up the great work!!!!

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

    Awesome explanation!
    Far better than the one of GeeksForGeeks

  • @Chelsea_Alexis
    @Chelsea_Alexis 8 років тому +1

    Thank you so much for making these helpful videos!! I watched this whole playlist before my dynamic programming exam and I got an A on it.

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

    What is time complexity of this program

  • @arunvyas27
    @arunvyas27 8 років тому

    Hello Tushar, can you also explain the surpasser count problem.

  • @deekshavarshney7224
    @deekshavarshney7224 8 років тому +1

    when i is at 6 its value gets increased to 2 because of 3 &4 then after that 0 & -1 is also less than 6 ,then why the value is not increased?

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

      The value of 0 and -1 is less than the value when i is 6,so this is not increased

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

    2022_06_24, I learned and implemented this good algorithm. Thank you!

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

    Program is failing for larger input. Example 1000 numbers. Namely it was getting timed out

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

    How to print the subsequence itself?

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

    very nice solution, thanks!

  • @vivekkds287
    @vivekkds287 11 місяців тому

    explanation couldnt get any better.

  • @daekyoung_jung
    @daekyoung_jung 7 років тому +1

    I think this lecture could be better if the lecturer had talked about analysis of time achieved by the suggested algorithm.

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

    What happens if you start with -1 at starting then value of j would never going to inc.

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

    y so serious dude?

  • @vishnuvardhan-cq7dr
    @vishnuvardhan-cq7dr 8 років тому +19

    Dude you just killed it !! Awesome explanation !!

  • @aashishrulz
    @aashishrulz 8 років тому

    can u elaborate if this can be done using matrix option, instead of memization, as u have done most of ur videos

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

    Thank you so much for making this video easy to understand. Keep going on!

  • @KiranKumarTalapaku
    @KiranKumarTalapaku 8 років тому

    question: element 6 has count as 3 and last element 3 has count 4 ? ... if element position of j < i then we need to increment count... you have done till element 6 got be 3.. why are you not increasing count at 6 ? where as you increased count for last element 3 even if 4 is not less than 3. am i missing you explanation ?
    can you please correct me if i m wrong.

    • @EalhamAlMusabbir
      @EalhamAlMusabbir 8 років тому

      Nope...
      At position i,
      lis(i) = max (
      1 + lis(i-1) if arr[i] > arr[i-1]
      1 + lis(i-2) if arr[i] > arr[i-2]
      1 + lis(i-3) if arr[i] > arr[i-3]
      ...
      )
      For the element 6, lis(4)=max(1+lis(3), 1+lis(2),1+lis(1),1+lis(0))=max(1+2, 1+1, 1+2, 1+1)=3
      Hope this helps... :)

  • @mausamdoshi4868
    @mausamdoshi4868 8 років тому

    Awesome solution! Can you create a video for finding Longest Consecutive Subsequence in unsorted array? e.g
    Input: arr[] = {1, 9, 3, 10, 4, 20, 2};
    Output: 4
    The subsequence 1, 3, 4, 2 is the longest subsequence
    of consecutive elements

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

      But they r not in sequential order. I have a doubt in it? Will u pls sort it out?

  • @RakeshGajjar
    @RakeshGajjar 7 років тому

    I stugled to understand this problem and referred other sources as well. This video gave me a final push to clear my understanding. Thanks Tushar!

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

    can we do better than O(n2) ?

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

    Write a program to find the longest progressive sequence arranged in ascending order in c

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

    this vid is 7 years old damnnnn

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

    Brilliant. Love you man.

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

    thank you so much Tushar Sir

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

    You are a legend.

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

    first time I found best video of LIS question.
    thanks from bottom of my heart!

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

    he seems a bit sad in the start

  • @roh9934
    @roh9934 7 років тому

    Time Complexity? O(n)? where n is length of array?

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

    Can anyone send me link ,I am not able to open it

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

      github.com/mission-peace/interview/blob/master/src/com/interview/dynamic/LongestIncreasingSubsequence.java
      If you're not able to open it then use VPN.

  • @mdzahidulislam4724
    @mdzahidulislam4724 7 років тому

    Nice explanation, subscribed after watching first video of this channel, thanks