412. Fizz Buzz Easy

@problem@discussion
#Math#String#Simulation



1/**
2 * [412] Fizz Buzz
3 *
4 * Given an integer n, return a string array answer (1-indexed) where:
5 * 
6 * 	answer[i] == "FizzBuzz" if i is divisible by 3 and 5.
7 * 	answer[i] == "Fizz" if i is divisible by 3.
8 * 	answer[i] == "Buzz" if i is divisible by 5.
9 * 	answer[i] == i (as a string) if none of the above conditions are true.
10 * 
11 *  
12 * Example 1:
13 * Input: n = 3
14 * Output: ["1","2","Fizz"]
15 * Example 2:
16 * Input: n = 5
17 * Output: ["1","2","Fizz","4","Buzz"]
18 * Example 3:
19 * Input: n = 15
20 * Output: ["1","2","Fizz","4","Buzz","Fizz","7","8","Fizz","Buzz","11","Fizz","13","14","FizzBuzz"]
21 *  
22 * Constraints:
23 * 
24 * 	1 <= n <= 10^4
25 * 
26 */
27pub struct Solution {}
28
29// problem: https://leetcode.com/problems/fizz-buzz/
30// discuss: https://leetcode.com/problems/fizz-buzz/discuss/?currentPage=1&orderBy=most_votes&query=
31
32// submission codes start here
33
34impl Solution {
35    pub fn fizz_buzz(n: i32) -> Vec<String> {
36        vec![]
37    }
38}
39
40// submission codes end
41
42#[cfg(test)]
43mod tests {
44    use super::*;
45
46    #[test]
47    fn test_412() {
48    }
49}
50


Back
© 2025 bowen.ge All Rights Reserved.