From 2f3dd4cb9f2fefe864b524be4ba40fa4357927ee Mon Sep 17 00:00:00 2001 From: Deven <63876261+devenperez@users.noreply.github.com> Date: Thu, 11 May 2023 20:30:43 -0400 Subject: [PATCH] Time: 30 ms (42.20%), Space: 14.1 MB (65.22%) - LeetHub --- 412-fizz-buzz/412-fizz-buzz.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 412-fizz-buzz/412-fizz-buzz.py diff --git a/412-fizz-buzz/412-fizz-buzz.py b/412-fizz-buzz/412-fizz-buzz.py new file mode 100644 index 0000000..59bde28 --- /dev/null +++ b/412-fizz-buzz/412-fizz-buzz.py @@ -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; \ No newline at end of file