My Calendar I - Leetcode 729 - Python

Поділитися
Вставка
  • Опубліковано 29 січ 2025

КОМЕНТАРІ • 17

  • @MehmetDemir-xi3yy
    @MehmetDemir-xi3yy 4 місяці тому +31

    Hey man I don't know if you did that but could you please solve a problem about Segment Tree to teach us? Thanks

  • @Ny_babs
    @Ny_babs 4 місяці тому +5

    My favorite thing about calendars is that the number of days is always less than 32 bit... trying to plant the seed of thought without saying much more. & | ^

  • @technophile_
    @technophile_ 4 місяці тому +2

    Solved to using TreeSet! Pretty easy tbh if you know what a TreeSet / Map is.

  • @10zDelek
    @10zDelek 4 місяці тому +3

    one day gonna code like this

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

    The writing of while True: on line 10 looks very dangerous. I suggest changing it to while curr: and then passing root into the insert() function on line 33.

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

    It would be great if you could create a solution using segment tree .One of the primary reasons I always look forward for your videos is because how well and intuitively you carry out the explanation of some advanced implementation or its reasoning and I have to say this is what separates you from the other creators. So such high level of content is highly expected and appreciated from your side . Nonetheless I had been having an amazing time learning from you and immensely grateful to you for how far I have come.

  • @antondonohue8943
    @antondonohue8943 4 місяці тому +2

    I'm not sure about the O(n^2) complexity here. book checks through every element in events. It's time scales linearly with the size of events I think it should be o(n).
    Keep up the good work Neet.
    - A

    • @jamesisaacson6414
      @jamesisaacson6414 4 місяці тому +2

      Lets see step by step:
      - When there are no elements, just insert -- 0 comparison
      - to insert second element, you do 1 comparison
      - to insert third element, you do 2 comparisons in worst case
      - to insert fourth element, you do 3 comparisons in worst case and so on
      by the time you insert the nth element, you do 0 + 1 + 2 + ..... + (n-1) comparisons in the worst case
      which sums up to n(n-2)/2 ~= O(n^2).
      Hope that helps!

  • @MP-ny3ep
    @MP-ny3ep 4 місяці тому

    Great explanation once again! Thank you for the daily.

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

    I think that also a SortedList could work, because we can have a list of integers (i will explain It later) and we can look of there Is a Number beetween the input, otherwise we will inser start and then end-1.
    [], then 1,10
    [1, 9]

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

    Hey Navi, do the interviewers allow us to use bisect_left/right methods? Sometimes these methods come very handy. Just wanted to be on the safe side.

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

    THANKS NEETCODE

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

    Can we also have a video for My Calendar 2? 🥰

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

    Meet please can you solve problems with segment tree we really need this

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

    Solved it!

  • @dontignore5567
    @dontignore5567 4 місяці тому +2

    I was doing this problem exactly 6 hours back 😂