dsa · easy

Fizz Buzz

For the integers 1 through n inclusive, build a list of strings of length n using these rules, in this priority:

Index 0 of the list is the rule for 1, index 1 is the rule for 2, and so on.

Example

n = 5:

Answer: ["1","2","Fizz","4","Buzz"].

n = 15 also hits 15, which is divisible by both 3 and 5, so that slot is "FizzBuzz" (not "Fizz" or "Buzz" alone).

## Arguments - n — inclusive upper integer; the list has length n

Constraints

1 <= n <= 4*10^4 Hidden tests include near-max size for this bound; a slower-than-intended solution TLEs.

Examples

Example 1

Input:
5

Expected:
["1","2","Fizz","4","Buzz"]

Example 2

Input:
1

Expected:
["1"]

Example 3

Input:
15

Expected:
["1","2","Fizz","4","Buzz","Fizz","7","8","Fizz","Buzz","11","Fizz","13","14","FizzBuzz"]

Open in the Dojo editor