Python! At Long Last!


  • 1
    H
    class Solution:
            # @param {integer} n
            # @return {integer}
            def countPrimes(self, n):
                primes=range(2,n)
                for i in primes:
                    if not i:
                        continue
                    for j in xrange(i*i,n,i):
                        primes[j-2]=0
                return len(primes)-primes.count(0)

  • 0
    D
    This post is deleted!

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.