Longest Ideal Subsequence - Leetcode 2370 - Python

10,849
0
Published 2024-04-24

All Comments (21)
  • @omarr993
    ngl i didn't get the bottom up approach explanation at all, I think it would probably be better to show the entire filled up grid of values for beginners to understand
  • @tinle6487
    This problem is kind of strange to me that normally I only able to come up with the recursion dp and have a hard time to do bottom up version, but in this case, I came up with the bottom up first
  • @kamahma
    Hi Neet. Thank you for leaving us some room to think about the problem, to draw it and try to visualize it! This was very helpful explanation video.
  • @TF2Shows
    Can someone explain whats the running complexity and memory complexity of both solutions? Im so confused
  • One thing to note is that the recursive solution passes if you use c++ and a 2d array for caching instead of python with hashmap. Great video!!
  • @rhitamdutta1996
    In my opinion the dfs approach was relatively simple and could have been avoided. It sucks that the dp approach was rushed, I had to look up other sources to understand it perfectly. I am used to Neet doing a top down approach, this bottom up did not make sense to me at all.
  • @aashishbathe
    @NeetCodeIO Hey, I didnt understand why caching was even needed in first solution. Like the same (i, prev) can never occur again right? Coz we are always increasing i? Can anyone please explain that?
  • @nasimnajand9697
    Thanks in advance but I have a question. why in bottom-up way we track all valid chars that have the suitable diff and we do not track the last char that made vali longest subsequence?
  • @DBagg-zz4ip
    Whew. Gonna put this one on hold until I do the LCS course.
  • @ramonsouza9846
    This one was really hard for me... I almost wished I could use dynamic escalation to buy more RAM and have my brute force 48gb hashset pass instead of having to use dynamic programing... 💀
  • @hamirmahal
    To echo some other comments, seeing more of the table filled in could be instructive. It might be useful to make "spinoff" videos that cover parts of the main video in more detail? This video was really helpful overall. Thanks for posting it!
  • @heiksable
    it never states anywhere in the problem description that the characters in the input string are unique, right? so the 2nd solution wouldn't work in that case since it assumes this
  • @HuyLe-tu4pj
    I understand your first solution but I have a trouble with the second
  • @ahmedtremo
    Why are setting dp[cur] = max(dp[cur], longest), I think we are only computing it once so we don't need the max function