Package g0401_0500.s0412_fizz_buzz
Class Solution
java.lang.Object
g0401_0500.s0412_fizz_buzz.Solution
412 - Fizz Buzz.
Easy
Given an integer n
, return a string array answer
( 1-indexed ) where:
answer[i] == "FizzBuzz"
ifi
is divisible by3
and5
.answer[i] == "Fizz"
ifi
is divisible by3
.answer[i] == "Buzz"
ifi
is divisible by5
.answer[i] == i
(as a string) if none of the above conditions are true.
Example 1:
Input: n = 3
Output: [โ1โ,โ2โ,โFizzโ]
Example 2:
Input: n = 5
Output: [โ1โ,โ2โ,โFizzโ,โ4โ,โBuzzโ]
Example 3:
Input: n = 15
Output: [โ1โ,โ2โ,โFizzโ,โ4โ,โBuzzโ,โFizzโ,โ7โ,โ8โ,โFizzโ,โBuzzโ,โ11โ,โFizzโ,โ13โ,โ14โ,โFizzBuzzโ]
Constraints:
1 <= n <= 104
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
fizzBuzz
-