Sieve of Eratosthenes | Count Primes | Leetcode 204

Sdílet
Vložit
  • čas přidán 25. 07. 2024
  • Time: O(n*log(log n)); www.geeksforgeeks.org/how-is-...
    Spane: O(n)
    Topic: Array
    Code:
    github.com/Nideesh1/Algo/blob...
    Leetcode:
    leetcode.com/problems/count-p...
    Note I claim no rights to this question. All rights belong to Leetcode. If I'm reviewing a solution that was from another Leetcode user or Leetcode itself I will give credit below.
    Credit to :
    Intro:(0:00)
    Input/Output/Approach:(0:11)
    Sieve:(0:33)
    Sieve Reasoning:(0:57)
    Code:(3:18)
    Dry Run:(4:08)
    Hey there! Just wanted to let you know that some of the below links in this video description are affiliate links, which means that if you make a purchase through them, I may earn a small commission. Don't worry though, it doesn't cost you anything extra and it helps support this channel so I can continue to make more videos for you. Thank you so much for your support, and as always, all opinions are my own!
    Start getting great at system design: bytebytego.com?fpr=nideesh (affiliate link)
    Handpicked Algorithms and Data Structures for Interview To Save Time: interviewpen.com/?via=nideesh (affiliate link)
    Fast track to becoming a knowledgeable SWE www.educative.io/unlimited?af... (affiliate link)

Komentáře • 16

  • @adhishmalviya2408
    @adhishmalviya2408 Před 4 lety +8

    it took me just 5 mins to understand Sieve of Eratosthenes, thanks to you

  • @cswithsamxd1883
    @cswithsamxd1883 Před rokem

    I generally do not comment on videos but i had to on this one.
    you are a good teacher because i just came to this video after watching 3 video on the same topic and i got the algo in 2 min of your video.

  • @trishalm1367
    @trishalm1367 Před 3 lety +1

    Thanks for making it simple and concise 😀

  • @theRIGHTshivam
    @theRIGHTshivam Před 3 lety

    Really helpful. Thanks a lot

  • @stutipandey7280
    @stutipandey7280 Před 3 lety

    Great Explanation

  • @darshantsdarshan1
    @darshantsdarshan1 Před 3 lety

    Understood Thanks!

  • @asthavijayvargiya4845
    @asthavijayvargiya4845 Před 3 lety

    Amazing explanation, I suscribed

  • @yashnandwal3366
    @yashnandwal3366 Před 3 lety

    thank you so much

  • @NideeshTerapalli
    @NideeshTerapalli  Před rokem

    Hey there! Just wanted to let you know that some of the links in this comment are affiliate links, which means that if you make a purchase through them, I may earn a small commission. Don't worry though, it doesn't cost you anything extra and it helps support this channel so I can continue to make more videos for you. Thank you so much for your support, and as always, all opinions are my own!
    Start getting great at system design: bytebytego.com?fpr=nideesh (affiliate link)
    Handpicked Algorithms and Data Structures for Interview To Save Time: interviewpen.com/?via=nideesh (affiliate link)
    Fast track to becoming a knowledgeable SWE www.educative.io/unlimited?aff=K1z6 (affiliate link)

  • @NhiNguyen-yo2pm
    @NhiNguyen-yo2pm Před 2 lety +1

    On the 2nd line: why do we need to create an array of len(n+1) ? why not len(n)? Are there any specific reasons?

  • @tv..6531
    @tv..6531 Před 3 lety

    czcams.com/video/0ABnO_WoexE/video.html
    를 이용하여
    1부터 1,000까지 사이에 있는
    소수의 개수(counting prime numbers)를 구하는 영상 입니다.

  • @lpdc9767
    @lpdc9767 Před 3 lety

    Still works if the boolean array is intialized to have just n elements instead of n + 1 for me using python.

  • @hakoHiyo271
    @hakoHiyo271 Před 3 lety

    How come they (leetcode) cannot explain like you do! Thanks!

  • @notarealhandle123
    @notarealhandle123 Před 2 lety

    It is nice, on the surface, but using `number` for storing bit flags is extremely sub-optimal in JavaScript, because `number` can store 53 bits, not 1.

  • @mrprime557
    @mrprime557 Před rokem

    Please explain how to calculate TC for this approach.