Design HashSet | Leet code 705 | Theory explained + Python code | August Leet code challenge

แชร์
ฝัง
  • เผยแพร่เมื่อ 2 ธ.ค. 2024

ความคิดเห็น •

  • @smart7868
    @smart7868 2 ปีที่แล้ว +1

    I thought, if you already have 2 in the set, adding another 2 will ignore it. but this algorithm will add another 2 anyway.

  • @abdifatahmoh
    @abdifatahmoh 3 ปีที่แล้ว +5

    Wow, nothing can be compared to your explanation, really helpful. Thank you!

  • @aditisurvase6381
    @aditisurvase6381 2 ปีที่แล้ว +2

    I believe sets shouldn't have elements repeating, those checks have not been done while inserting.

  • @spark9_
    @spark9_ 9 หลายเดือนก่อน +1

    thanks for explaining HashSet so well

  • @rockmanvnx6
    @rockmanvnx6 3 ปีที่แล้ว +2

    For your add you need to check if it contains. What if we add duplicate values

  • @maamounhajnajeeb209
    @maamounhajnajeeb209 ปีที่แล้ว

    a very good step by step approach

  • @kylehammerberg3875
    @kylehammerberg3875 2 ปีที่แล้ว +2

    Great explanation, man. Simple and straightforward.

  • @buildwithcarolina2811
    @buildwithcarolina2811 2 ปีที่แล้ว +1

    Wonderful explanation! You are literally the best!!!

  • @praneeth1995
    @praneeth1995 4 ปีที่แล้ว +2

    Awesome buddy... Keep up your good job.. You are educating so many people...

  • @lingyuhu4623
    @lingyuhu4623 2 ปีที่แล้ว

    Easy to understand, thank you. But I'm just wondering that the hashset should be with unique elelment?

  • @pythonenthusiast9292
    @pythonenthusiast9292 4 ปีที่แล้ว +1

    Shouldnt you initialize your table as something like [ [ None ] for i in range(self.size) ] as you are appending incase of a collision because the individual elements are not of class list? what do you think?

    • @saianishmalla2646
      @saianishmalla2646  4 ปีที่แล้ว +1

      Now that I think about it, it makes sense to use list comprehension. By using list comprehension each element is uniquely referenced but by using '*' we're making a reference to the same object for x amount of times.

    • @pythonenthusiast9292
      @pythonenthusiast9292 4 ปีที่แล้ว

      @@saianishmalla2646 but what * is doing is basically making n number of entries of None but for our program to tackle collision the entries should be of type list right so that we can append on it.. basically meaning that the entries should be
      [ None ]

    • @saianishmalla2646
      @saianishmalla2646  4 ปีที่แล้ว +1

      @@pythonenthusiast9292 Actuallly no. We are doing [None] * size the result of that is a list itself so in that way I don't think it's a problem.

    • @edithpuclla6188
      @edithpuclla6188 3 ปีที่แล้ว

      Why did he initialize the backed in 10000 and, not in 10^6? . It is because of the number of calls? "At most 10^4 calls will be made to add, remove, and contains."

  • @yunaf4609
    @yunaf4609 2 ปีที่แล้ว

    Amazing explanation, thanks for this :)

  • @yhgong8109
    @yhgong8109 ปีที่แล้ว

    thank u so much, it really helped a lot

  • @ajayprajapati2453
    @ajayprajapati2453 2 ปีที่แล้ว

    very nicely explained!!!

  • @jeevansch.5599
    @jeevansch.5599 2 ปีที่แล้ว

    Awesome video bro, well explained, because of you today i learned something.

  • @ogoubah
    @ogoubah 3 ปีที่แล้ว

    Really understood the concept, thanks!

  • @nikitajaiswal9112
    @nikitajaiswal9112 3 ปีที่แล้ว

    Amazing explanation.

  • @jaishivnani7768
    @jaishivnani7768 4 ปีที่แล้ว +1

    Your video is epic Thankyou so much

    • @jaishivnani7768
      @jaishivnani7768 4 ปีที่แล้ว +1

      SyntaxError: invalid syntax
      ^
      def add(self, key: int) -> None:
      Line 10 (Solution.py) i am getting this error and unable to solve this could you help?

    • @saianishmalla2646
      @saianishmalla2646  4 ปีที่แล้ว

      Thank you!

    • @saianishmalla2646
      @saianishmalla2646  4 ปีที่แล้ว

      Yeah if you get rid of the :int and the -> None it should work

    • @jaishivnani7768
      @jaishivnani7768 4 ปีที่แล้ว

      @@saianishmalla2646 Thanks

  • @souravkumarcode
    @souravkumarcode 4 ปีที่แล้ว +1

    Good job man.!

  • @annamur6143
    @annamur6143 7 หลายเดือนก่อน

    Thank you!

  • @ashutoshshrivastava6521
    @ashutoshshrivastava6521 4 ปีที่แล้ว +1

    great explanantion

  • @tl8035
    @tl8035 3 ปีที่แล้ว

    Great vid! However, none of these functions actually give O(1) time complexity like a built-in hashset. Do you have any other alternatives?

  • @ishayadav5221
    @ishayadav5221 4 ปีที่แล้ว +1

    AMAZING

  • @zero-codm8164
    @zero-codm8164 2 ปีที่แล้ว

    nice

  • @zero-codm8164
    @zero-codm8164 2 ปีที่แล้ว

    wow