Python 1-line, no branching, 88ms


  • 0

    Uses string multiplication and int(True) == 1, int(False) == 0

    return [str(i)*int(i%3>0)*int(i%5>0) + 'Fizz'*int(not i%3) + 'Buzz'*(not i%5) for i in xrange(1,n+1)]
    

Log in to reply
 

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