Time: 30 ms (42.20%), Space: 14.1 MB (65.22%) - LeetHub

This commit is contained in:
Deven
2023-05-11 20:30:43 -04:00
parent f19f7311a6
commit 2f3dd4cb9f
+19
View File
@@ -0,0 +1,19 @@
class Solution(object):
def fizzBuzz(self, n):
"""
:type n: int
:rtype: List[str]
"""
array = []
for i in range(1, n + 1):
if i % 15 == 0:
array.append("FizzBuzz")
elif i % 3 == 0:
array.append("Fizz")
elif i % 5 == 0:
array.append("Buzz")
else:
array.append(str(i))
return array;