Best Team with no Conflicts - Leetcode 1626 - Python

Поделиться
HTML-код
  • Опубликовано: 14 окт 2024

Комментарии • 38

  • @NeetCodeIO
    @NeetCodeIO  Год назад

    Explanation of Longest Increasing Subsequence (an easier variation of this problem): ruclips.net/video/cjWnW0hdF1Y/видео.html

  • @Lulit999
    @Lulit999 Год назад +13

    It is pretty strange to see that your videos have that small amount of viewers, but thank you for your effort - I do leetcode regularly for 6 months and for the time being my the best achievement is 345 place in the last biweekly contest. I would not be able to do such a big progress in algorithms/competitive programming that quickly without your help :)

    • @champion5946
      @champion5946 Год назад +1

      it's not a old video that it will have high views

    • @infiniteloop5449
      @infiniteloop5449 Год назад

      Neetcode changed RUclips channels to neetcodeIO recently and I think a lot of people who used to subscribe didn’t realize it yet.
      @NeetcodeIO might help with the account migration to post a video on the original channel to divert users to this channel.

  • @shahidilhan3139
    @shahidilhan3139 Год назад +16

    Shouldn't dp[2] be 9 instead of 10, as its basically the max sum of the first three scores that is 1+3+5?

    • @NeetCodeIO
      @NeetCodeIO  Год назад +12

      Yep you're right, somehow I messed up the basic addition 🤣

  • @LeiCao-yp7zk
    @LeiCao-yp7zk 8 месяцев назад +1

    Thanks for the video! But I do want to point out that when you sort the array of pairs. It is important to also sort the ages in ascending order when the scores are equal (at least for c++ when writing a custom comparator). If not it will fail the test case when all scores are equal. In your video you said it doesn’t matter on the ages :)

    • @roderickli6505
      @roderickli6505 4 месяца назад

      I don't know how more people mention this! Bless up
      lst = [[scores[i], ages[i]] for i in range(len(scores))]
      lst.sort(key = lambda x : (x[0], x[1]))

  • @randomlyasked
    @randomlyasked Год назад +2

    Absolutely loving the daily solutions, thanks a lot 😃

  • @denysDenys2749
    @denysDenys2749 Год назад +1

    Great solution for the medium-hard (on my opinion) problem. Thank you for sharing it!

  • @wycode
    @wycode Год назад

    It's possible to get accepted using the first approach in Python. All you need to do is convert the recursive approach to an iterative approach. Another note is that you can optimize the solution by only referencing i + 1 while calculating the solution. This means we can even optimize the solution to have O(n) space complexity, making it the same as the second solution in terms of time and space complexity, but without needing to know anything about LIS (Longest Increasing Subsequence) in advance.

  • @pauljones9150
    @pauljones9150 Год назад

    If you do this question on leetcode, you'll notice that some solutions take advantage of the fact that there are never more than 2 duplicates in the test. This allows for sorting, then indexing to be done, resulting in a much simpler solution. But imo this answer is better

  • @T_tintin
    @T_tintin Год назад

    I was just reading this leetcode question for like 10 minutes and started feeling sleepy but just when I was just about to fall asleep , it suddenly hit me and I was like wait is this a LIS problem? loll . Yea I am still new to recurssion and stuff but I felt so happy when it hit me that I woke up instantly .. lol it was kinda funny.

  • @shreshthkushwaha
    @shreshthkushwaha Год назад

    Same man I also got TLE from recursive python. I think leetcode loaves tabulation

  • @mohithadiyal6083
    @mohithadiyal6083 Год назад

    Easiest explanation ever ♥️

  • @iamnoob7593
    @iamnoob7593 Месяц назад

    Thanks neetcode

  • @tofahub
    @tofahub Год назад

    I think the memoization solution had a bug inside the add score recursive call. The second parameter shouldn't be i

  • @krateskim4169
    @krateskim4169 Год назад

    Beautiful solution

  • @piesquareisg
    @piesquareisg Год назад

    Are these videos also added on the netcode site when they are uploaded? How much time does it take?

    • @NeetCodeIO
      @NeetCodeIO  Год назад +1

      I could add them pretty quickly, but the list has over 300 problems and idk how long I want it to get.

  • @MP-ny3ep
    @MP-ny3ep Год назад

    Thank you , this is really really helpful

  • @ouchlock
    @ouchlock Год назад

    Awesome as always. Thanks.

  • @krateskim4169
    @krateskim4169 Год назад

    Awesome explanation

  • @erassylzh5658
    @erassylzh5658 Год назад

    Thank you!

  • @scresat
    @scresat Год назад

    Thank you so much!

  • @yang5843
    @yang5843 Год назад

    Did anyone get the recursive code working?

    • @NeetCodeIO
      @NeetCodeIO  Год назад

      I think my recursive code was working but it was TLE in python at least

  • @amansarma417
    @amansarma417 Год назад +1

    Bro grinding leetcode hard he knows he's going to get Laid :(

    • @NeetCodeIO
      @NeetCodeIO  Год назад +14

      ...off

    • @amansarma417
      @amansarma417 Год назад

      Jk bro 🌚your videos are helping me alot too thanks ❤

    • @pauljones9150
      @pauljones9150 Год назад

      @@NeetCodeIO RIP is the vibe at Google still down? No one is safe?

    • @0xatul
      @0xatul Год назад

      @@NeetCodeIO lmfaoo

    • @hrithik7354
      @hrithik7354 Год назад

      ​@@amansarma417 No bro, he is taking it gravely. Now u have to pay for it praising will not work XD

  • @CostaKazistov
    @CostaKazistov Год назад +5

    Newest style of video edits that deletes gaps between sentences sounds really weird.
    Much prefer your earlier style where videos included natural gaps between sentences.

    • @NeetCodeIO
      @NeetCodeIO  Год назад

      Are there any specific moments in the video you're referring to? I feel most of my videos are edited this way.

    • @CostaKazistov
      @CostaKazistov Год назад

      @@NeetCodeIO First part of the video, conceptual overview, felt like it was done on a single breath.
      Pauses are normal only between timestamped chunks of the video.
      The walkthrough seems more like a run-through, requiring manually pausing video too frequently, in order to understand the explanation.

    • @NeetCodeIO
      @NeetCodeIO  Год назад +2

      I see your point, but I'd prefer to keep the videos shorter rather than longer. Having pauses would be subjective, some ppl want them but others wouldn't. Viewers can pause themselves, but they can't cut out the silences.

    • @govindbanura3327
      @govindbanura3327 Год назад +1

      @@CostaKazistov I also feel the same as you. But now I start watching these video on 0.75x speed, which sounds exactly as before. Try that.