FastPrepFizzBuzz
Problems/FizzBuzz

FizzBuzz

Indeed logoIndeed● EasyNEW GRADOA
QuestionFunctionExamplesConstraints

Problem statement

Source note: The report lists LeetCode's FizzBuzz as the first of four questions and gives only the name. It says the test came from the Indeed Prime platform, not Indeed's own hiring test.

Here you get n and return the strings for 1 to n, using the usual words Fizz, Buzz and FizzBuzz for multiples of 3, 5 and both. n is at most 1000, which is a practice choice.

The judged task matches the report at about 80%.

Given a whole number n, return a list of n strings, one for each number from 1 to n in order. For each number i:

  • If i is a multiple of both 3 and 5, the string is "FizzBuzz".
  • Otherwise, if i is a multiple of 3, the string is "Fizz".
  • Otherwise, if i is a multiple of 5, the string is "Buzz".
  • Otherwise, the string is i written in decimal, such as "7".

Function

fizzBuzz(n: int) → List<String>

Examples

Example 1

n = 1return = ["1"]

Only the number 1, which is not a multiple of 3 or 5, so it stays "1".

Example 2

n = 10return = ["1","2","Fizz","4","Buzz","Fizz","7","8","Fizz","Buzz"]

3, 6 and 9 are multiples of 3 and become "Fizz". 5 and 10 are multiples of 5 and become "Buzz". The other numbers stay as they are.

Example 3

n = 16return = ["1","2","Fizz","4","Buzz","Fizz","7","8","Fizz","Buzz","11","Fizz","13","14","FizzBuzz","16"]

15 is a multiple of both 3 and 5, so it becomes "FizzBuzz", not "Fizz". 16 is neither, so it stays "16".

Constraints

  • 1 <= n <= 1000

More Indeed problems

  • Insert into an Unrolled Linked ListPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Course Completion OrderPHONE SCREEN · Seen May 2025
  • Recipes You Can PreparePHONE SCREEN · Seen May 2025
All Indeed interview questionsSee Indeed hiring insights
Saved
class Solution {
    public List<String> fizzBuzz(int n) {
        // Write your code here.
    }
}
Checking account…