Practice Fizz Buzz Multithreaded
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Implement FizzBuzz(n) for four threads sharing one instance. One calls fizz(printFizz), one buzz(printBuzz), one fizzbuzz(printFizzBuzz), and one number(printNumber). Coordinate the callbacks to output one token for each integer i from 1 through n in order: "fizzbuzz" for multiples of both 3 and 5, "fizz" for other multiples of 3, "buzz" for other multiples of 5, and i otherwise. Each method must use its corresponding callback; printNumber receives the integer to print.
Source: Fizz Buzz Multithreaded on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
n = 15
[1,2,"fizz",4,"buzz","fizz",7,8,"fizz","buzz",11,"fizz",13,14,"fizzbuzz"]
# Example 2
n = 5
[1,2,"fizz",4,"buzz"]
Constraints
Related LeetCode Problems
Practice more problems similar to Fizz Buzz Multithreaded.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.