Longest Increasing Subsequence | Dynamic Programming

Поділитися
Вставка
  • Опубліковано 12 вер 2024
  • Please consume this content on nados.pepcoding.com for a richer experience. It is necessary to solve the questions while watching videos, nados.pepcoding.com enables that.
    NADOS also enables doubt support, career opportunities and contests besides free of charge content for learning. In this video, we explain about subsequences and discuss the Longest Increasing Subsequence problem in dynamic programming, In this problem,
    1. You are given a number n, representing the number of elements.
    2. You are given n numbers, representing the contents of array of length n.
    3. You are required to print the length of longest increasing subsequence of array.
    To submit this question, click here: www.pepcoding....
    For a better experience and more exercises, VISIT: www.pepcoding....
    Have a look at our result: www.pepcoding....
    Follow us on our FB page: / pepcoding
    Follow us on Instagram: / pepcoding
    Follow us on LinkedIn: / pepcoding-education

КОМЕНТАРІ • 197

  • @carpediem5112
    @carpediem5112 3 роки тому +81

    I have never commented on any channel but you are the mentor I was looking for years. I have watched many youtube videos on dp, no one explained the 'WHY'. Great explanation, great content...specially the way of teaching. JABRA FAN BANGYA DADA .

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

    Seriously, you guys have proved, that Indians have so much talent and some of the best explanations... Sincere thanks for the fantastic videos.

  • @anchalpandey2787
    @anchalpandey2787 3 роки тому +23

    The best lecture series available on youtube for DP

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

      Thankyou beta,
      I am glad you liked it. I also hope that you are watching till end.
      If you like our efforts, will you like to write a few words about us here (www.quora.com/How-do-I-start-learning-or-strengthen-my-knowledge-of-data-structures-and-algorithms )

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

    I am watching tutorials from last couple of years, you are one of the best teacher. Amazing

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

      wow, this cheers me up. I am glad we at pepcoding could be of help to you. Keep learning. Also, recommend us to your juniors and peers, they may also benefit.

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

    I have watched several videos but have never seen such a detailed explanation. Hats off to you bro. Thanks a lot.

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

    I tried to look for the answer in many other channels but no one explained the way you did from scratch. Thank you sir it's really amazing

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

      I am glad you liked it. I also hope that you are watching till end and trying to understand the what, how and especially why of the problem.
      If you like our efforts, we request a review
      g.page/Pepcoding/review?rc
      You can subscribe to our channel here
      ua-cam.com/users/Pepcodingabout?view_as=subscriber

  • @sarangr8624
    @sarangr8624 3 роки тому +6

    Your channel deserves Millions of followers 👍

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

      Maybe one day. Thank you so much keep motivating, keep learning and keep loving Pepcoding😊

  • @_HarshitSharma
    @_HarshitSharma 2 роки тому +2

    I'm literally amazed sir ji! I watched this video at almost 3:50 am in the middle of the night when I was struggling to sleep, and I still can't believe I actually understood the whole approach and concept of this popular classical dp problem. Thankyou so much Sir ♥️ @pepcoding you simply rock! Can't wait to mark the submission for this question on your platform in the morning ⚡⚡

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

      That really means a lot. For better experience and well organised content sign up on nados.io and start learning.

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

    the best explanation i got for this problem. Sir i have learnt a lot from you. You are really a bliss

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

    sir jis tarah se ap samjhate ho hr problem asan lgti h
    yeh question pehli bar itna acche se samajh aya h

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

    Thank you sir for posting amazing content for free 😀😀. I am sure many students will get benefit from these videos.

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

    Very nice and crystal clear explanation. I loved the concept of answering the 'what' and 'how' and then answering the 'why' of the problem. Loved it!!

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

      Thankyou beta!
      I am glad you liked it. It's all with the effort and hardwork from our brilliant mentors(Subhesh sir and all the other teacher of pepcoding). If you like our efforts, will you like to write a few words about us here (www.quora.com/How-do-I-start-learning-or-strengthen-my-knowledge-of-data-structures-and-algorithms )

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

    Hands down all other channels were jzt telling the algo but not the intimation and the reason but u xplained it well 🔥

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

    Wow!! What else can be better than this explanation.

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

    explained it very well sir.... aapka style hi alg hai smjane ke.

  • @SonuKhan-mp2yn
    @SonuKhan-mp2yn Рік тому +1

    million dollar content. Thank you so much sir.

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

    Great Explanation sir! i will not believe if anyone says that he can explain this question better than you, keep going sir, Awesome !!

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

      for better experience why don't you use this same content on nados.pepcoding.com?

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

    can be done in O(N log N) if we want to find only the length
    using a temp array and a lower bound
    1. push the first element in the array
    2. now loop(1,N) if arr.back() just push curr_element to the arr
    else find lower bound of curr_element from arr and replace with curr_element
    hopefully i make sense :|

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

      hanji, have been mentioned in the video ki iska better approach hai isse.

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

    Again hatsoff to you sir, your explanation is so raw , so down to earth, no rocket science i m literally now a very big fan of your explanation . Yesterday i watched kadanes algorithms u nailed it today i saw this video u again blown my mind , your concept of What Why and How is very much helpfull. Knowledge which u deliver to us in such a systematic way is awesome it got smoothly into my head .
    I m realising it was just hype about DP after seeing ur explanation i m too much Nischint. Thankx a lot sir.
    Sir please explain this Q in NLogN also, I m now habituated to your way of explanation so now no videos are suiting my slow brain.

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

      Thankyou beta, for such kind words.
      I am glad you liked it. If you like our efforts, will you like to write a few words about us here (www.quora.com/How-do-I-start-learning-or-strengthen-my-knowledge-of-data-structures-and-algorithms )

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

      Sure sir.

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

      Same i love his videos!

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

    One of the best teaching style!! Thanks a lot. From Bangladesh :D

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

    काफी स्पस्ट व्यवरण मित्र।

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

    you deserve million subscribers ... lots of love❤️❤️❤️

  • @stark1862
    @stark1862 19 днів тому

    Summit Bhaiya, Tussi Great Ho!

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

    You are guru of coding ...Best teacher ever

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

      wow, this cheers me up. I am glad we at pepcoding could be of help to you. Keep learning. Also, recommend us to your juniors and peers, they may also benefit

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

    this is by far the best explanation according to me

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

    Sir this question needs to be solved in O(nlog(n)) we need to optimise further

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

    One thing that makes u different and beautiful is thinking about what ..why and how of problem.lots of love sir ji

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

      Thank you for appreciating.
      The love and respect which I get from you people keep me highly motivated and the same I am able to forward It to you people through my videos.
      So, keep motivating, keep learning and keep loving Pepcoding😊

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

    Dear Sumeet, may you attain eternal peace, longevity, health and vitality.

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

    Just amazing, you have helped me a lot in clarifying my dp concepts.

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

    Fantastic explanation sir👏👏 thanks a lot

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

    thankyou sir for the amazing tutorials

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

    Kya hi gazab padhate ho sir aap! THANK YOU

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

    mindblowing solution no doubt

  • @ShubhamRaj-tm9ui
    @ShubhamRaj-tm9ui 3 роки тому +5

    sir,please do upload video on this topic using recursion with memorization.

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

      Beta, recursion main itne question ho gye h, ki bacho ki thinking capability bn jaye ki vo naye question ki recursion khud se soch paye, issliye dynamic programming ki series main directly dp solution krvaya gya h. But if you are facing some problem or for clearing your doubts, you can join our community on telegram - t.me/pepcoding

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

      @@Pepcoding sir recursion ki playlist main mostly recursion on the way wale questions hai ,kuch faith wale thode add kr dijiye sir jisse dp mai bhi memoise krne mai problem na ho please

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

    Superb explanation sir!

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

    Thank You sir !

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

    Sumeet sir, maza aagya!

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

    Great way of explaining. This way complex problems become very simple.

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

      Glad it was helpful!
      Keep learning.
      And for better experience and well organised content visit nados.pepcoding.com

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

      @@Pepcoding Can you please provide the solution for this problem for n(log n) approach

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

      For better insight, visit nados.pepcoding.com, , post your doubts, community will help you out there.

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

    Great explanation again!!! Also sir, DP has only been taught through questions? Or is there theory about it too, if yes where can i find it.

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

      Thankyou beta!
      I am glad you liked it.
      Will you like to write a few words about us here (www.quora.com/What-are-the-good-websites-to-learn-data-structures-and-algorithms)
      Hanji, It is taught through questions only, basically jha bhi overlapping subproblem dikhe apko, vha dp lgate h hum.

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

    Sirji ek baar mein samajh aa gya recursion/memoization se tle aa rha tha, tabulation sahi hai!

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

      Glad to hear that for better experience and well organised content visit - nados.io

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

      can you pls share recursive/ memoized solution for this problem. 🙏🙏

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

    Thank your sir for such logical explanation Glad I reached to your videos!

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

      Thankyou beta!
      I am glad you liked it. I hope that you are watching till the end and trying to understand what, how, and especially why of the problem.
      If you like our efforts, will you like to write a few words about us here (www.quora.com/What-are-the-good-websites-to-learn-data-structures-and-algorithms )

  • @ayush.choudhary
    @ayush.choudhary 2 роки тому +1

    Great Explanation...👍👍

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

    Thanks brother lots of love

  • @444not
    @444not 3 роки тому

    Thank you ! very happy I found your channel.

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

    Sir Thank you very much.. Your explanation is the best.

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

    really brother i watched like 7 videos to understand what u said it was nice

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

      Thank you so much Bhai keep motivating, keep learning and keep loving Pepcoding😊

  • @GopalKumar-py2cf
    @GopalKumar-py2cf Рік тому

    awesome explanation sir

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

    best content for lis.
    superb explained!!!

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

    Thank you Sumeet sir

  • @AmanSharma-vb5jl
    @AmanSharma-vb5jl 2 роки тому

    you are simply awesome

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

    24:58, we can write int omax=1; at line number 16.

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

      what if input array length is itself 0 :))

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

      @@vinayjangra1401 leetcode problem number 300, please do check the constraints regarding the length of an array!

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

    Explanation is just awesome...Thank you sir.

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

      You are most welcome and If you like our efforts, please upvote the comments written by the students about Pepcoding here (www.quora.com/What-are-the-good-websites-to-learn-data-structures-and-algorithms )

  • @AnkitSingh-zj2uc
    @AnkitSingh-zj2uc 4 роки тому +1

    So finally you added TC
    Thanks sir

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

    jab bure din aate h toh, Input lena pdhta h - sumeet malik(sept 9,2020)

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

    Brilliant explaination

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

      Glad you love the explanation.
      For better experience and well organised content sign up on nados.io and don't forget to follow us on Instagram instagram.com/pepcoding/

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

    Amazing explanation. Thank you.

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

      I am glad you liked the content and thankyou for appreciating😊
      If you like our efforts, will you like to write a few words about us here (www.quora.com/How-do-I-start-learning-or-strengthen-my-knowledge-of-data-structures-and-algorithms )

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

    Thanks for the explanation really helpful.

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

      I am glad you liked it. I also hope that you are watching till end and trying to understand the what, how and especially why of the problem.
      If you like our efforts, we request a review
      g.page/Pepcoding/review?rc
      You can subscribe to our channel here
      ua-cam.com/users/Pepcodingabout?view_as=subscriber

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

    Best Explanation!!

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

      You can get more content like this on nados.pepcoding.com

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

    Can this question be done with lcs of original array with sorted array? I am facing some problems if there are repeated items present in the array.

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

      Beta, I regret to inform you that, I won't be able to answer/solve the personal doubts of each and every student over here. For clearing your doubts, you can join our community on telegram - t.me/pepcoding.

  • @md.monjormorshed2046
    @md.monjormorshed2046 2 роки тому

    Is it a Dynamic Programing approach?

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

    LEGEND!!

  • @RishabhJain-hr6sz
    @RishabhJain-hr6sz 2 роки тому

    kuch alag he baat hai!!

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

      Keep learning.
      And for better experience, visit nados.io, where you will get well curated content and career opportunities.

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

    Great Explanation .....Deserves ......Integer.MAX_VALUE (no. of likes)

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

    Sir could you please teach for the c and c++ background students also..i.e., as you are using int and Integer .. those are different for java nd c++..so y could not you use -1 insted of null..?

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

      you can use min value, and add a check at end, if it is still equal to min value. -1 won't work if array has negative numbers.

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

    Thank you, sir

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

    @sir where to find your video for nlogn solution for this problem ?

  • @HarshKumar-nh6be
    @HarshKumar-nh6be 4 роки тому +1

    Great teaching! :)

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

      Glad it was helpful!

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

    why the condition is if( arr[j] < arr[i] ) ? Why not if(arr[j]

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

    Best explanation 👍

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

    nice explanation

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

    Thanks for sharing these content sir!

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

      Glad you like them! and If you like the content could you post something on LinkedIn about us? This will help us in reaching out to more people and help a lot of other students as well
      Something like this
      Sumeet Malik from Pepcoding is making all his content freely available to the community
      You can check it out here - www.pepcoding.com/resources
      /
      Also, this is the youtube channel - ua-cam.com/users/Pepcodingplaylists?view_as=subscriber

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

      @@Pepcoding definitely

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

    sir can hashmap be used key will be value in array and value will be a integer array if while traversing greater is found pus it into arraylist and return the size of maximum length arraylist

  • @444not
    @444not 3 роки тому

    Maza aa Gaya dost. What’s the story behind pepcoding?

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

    how can we do "what" and "how" before "why" while solving it on our own.

  • @AyushRaj-pm1dz
    @AyushRaj-pm1dz 2 роки тому

    Can anyone give the link for the NLOGN approach video by sir.....

  • @Bobby-mf6fw
    @Bobby-mf6fw 3 роки тому

    Sir fabolus 🔥🔥go ahead...🏫

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

      If you like my efforts, I request a review
      g.page/Pepcoding/review?rc

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

    Brilliant!!

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

    Sumeet Sir is the OG

  • @Nikhil-qd9up
    @Nikhil-qd9up 3 роки тому

    Great explaination sir 🔥, sir can u please explain the binary search wala method of the above problem

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

      Thankyou buddy!
      I regret to inform you that, I won't be able to answer/solve the personal doubts of each and every student over here. For clearing your doubts, you can join our community on telegram - t.me/pepcoding.

  • @GhumiGhumi-s
    @GhumiGhumi-s 3 роки тому

    Great explanation! Can you please explain nlogn approach also!

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

      Buddy may b we will cover this in level-3 playlist.

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

    Great explanation 👍

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

    sir leetcode pe ek test case pass nhi ho raha jab sare elements same hai array mei like(4,4,4,4) to ans one hona chahiye but 4 aa raha hai..

  • @NaushadAli-uq1ss
    @NaushadAli-uq1ss 3 роки тому

    W h w concept is goldust

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

    Brilliant

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

    witness the awesomeness

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

    well explained sir! Thankyou

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

    Sir memoization chor du kya

  • @user-wd8tg9mr1h
    @user-wd8tg9mr1h 2 роки тому

    Sir, how to print the longest increasing sequence?

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

    understood

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

    Hi sir it would be of great help ,if you would help us with notes such as algorithm ,although it is quite clear from the code ,but looking back after some time say 6 months back, sometimes things vanish ,so it's helpful to take a basic key important note .Getting them would be of help

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

    Sir, what is your name? I am a BIG FAN of yours.

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

    I think this algorithm is called the Patience algorithm. Similar to Solitaire game.

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

    Thankyou Sir!

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

    Very nice explanation...

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

      Thankyou beta,
      Glad to know that you liked the content and thank you for appreciating. If you like our efforts, will you like to write a review about us here - g.page/Pepcoding/review?rc

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

      @@Pepcoding sure sir

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

    sir interviews me yeh chal jayega ya nlogn (Binary Search) waala expect karega interviewer?

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

      beta, unless specifically asked. this is the default one

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

    8/79 Done

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

    SIR iski nlogn wali approach ki bhi video bna do pls.

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

    Using Tabulation Directly How You Decide Wheter The Question Is Solved By 1D,2D or ND array Will Be Used.

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

      Post your queries on nados.pepcoding.com our community will help you out.

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

    sir interview me agar WHAT How pehle btayenge so will not Interviewer think he has crammed it !!!

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

      Yes, you will have to plan and say that I will be explaining it layer by layer. What's, how's and why it

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

    majha aa gya