FizzBuzz Solution(Python)


  • 0
    G
    class Solution:
        def fizzBuzz(self, n):
            """
            :type n: int
            :rtype: List[str]
            """
            L = []
            for i in range(n):
                i = i+1;
                temp = ""
                if i%3 == 0:
                    temp = temp + "Fizz"
                if i%5 == 0:
                    temp = temp + "Buzz"
                if (i%3)*(i%5) != 0:
                    temp = str(i)
                L.append(temp)
            return L
    

Log in to reply
 

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