MediumNo. 1195

Fizz Buzz Multithreaded — LeetCode 1195 Python Solution

Topics
Concurrency
Reading time
2 min

The problem

You have the four functions: printFizz that prints the word "fizz" to the console, printBuzz that prints the word "buzz" to the console, printFizzBuzz that prints the word "fizzbuzz" to the console, and printNumber that prints a given integer to the console. You are given an instance of the class FizzBuzz that has four functions: fizz, buzz, fizzbuzz and number.

Example

Input
n = 15
Output
[1,2,"fizz",4,"buzz","fizz",7,8,"fizz","buzz",11,"fizz",13,14,"fizzbuzz"]

Complexity

Time
O(n)
Space · auxiliary
O(1) to O(n)

Related problems

Related problems
No.ProblemDifficulty
0412Fizz BuzzEasy
1114Print in OrderEasy
1115Print FooBar AlternatelyMedium
1116Print Zero Even OddMedium
1117Building H2OMedium
0057Insert IntervalMedium

Frequently asked questions

How hard is LeetCode 1195. Fizz Buzz Multithreaded?

LeetCode 1195. Fizz Buzz Multithreaded is rated Medium on LeetCode.

What topics does LeetCode 1195. Fizz Buzz Multithreaded cover?

LeetCode 1195. Fizz Buzz Multithreaded is tagged Concurrency on LeetCode.

Stuck on problems like this in a live interview?

Stealth Interview is a desktop app for macOS and Windows. It reads the problem off your screen and returns a working solution with a step-by-step explanation and its time and space complexity, invisible to screen sharing.

Free to download. Check it runs on your machine, then pick a plan.