We got more and more recently.. Straightforward python solution


  • 3
    T
    class Solution(object):
        def fizzBuzz(self, n):
            """
            :type n: int
            :rtype: List[str]
            """
            res=[]
            for i in range(1,n+1):
                tmp=''
                if i%3==0:
                    tmp+='Fizz'
                if i%5==0:
                    tmp+='Buzz'
                if tmp=='':
                    tmp+=str(i)
                res.append(tmp)
            return res
    

Log in to reply
 

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