Label the Cadence Slots

Intermediate

A calendar view labels each slot 1..n: slots on the 3-cadence read "Fizz", on the 5-cadence "Buzz", on both "FizzBuzz", and everything else shows its number as text.

Implement `solve(Integer n)` to return a List<String> for 1..n where multiples of 3 are "Fizz", multiples of 5 are "Buzz", multiples of both are "FizzBuzz", and all others are the number as a string.

Examples

Inputn = 5
Output["1", "2", "Fizz", "4", "Buzz"]
Inputn = 3
Output["1", "2", "Fizz"]
Hints
  • Check divisibility by 15 first (both), then 3, then 5, else String.valueOf(i).
Anonymous Apex

Your code runs in a secure sandbox against multiple hidden test cases. The problem is solved only when every test passes. Each run is isolated and any data changes are rolled back automatically.