mirror of
https://github.com/devenperez/leetcode.git
synced 2026-06-13 03:27:07 +00:00
Time: 30 ms (42.20%), Space: 14.1 MB (65.22%) - LeetHub
This commit is contained in:
@@ -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;
|
||||
Reference in New Issue
Block a user