Xrange is essential here.


  • 0
    L

    I cannot pass the test if I use range instead of xrange.
    """
    def countPrimes(self, n):
    ls = [True]n
    count = 0
    for i in xrange(2,n):
    if not ls[i-1]:
    continue
    else:
    count+=1
    for j in xrange(i
    i,n,i):
    ls[j-1] = False
    return(count)
    """


Log in to reply
 

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