class Solution {
public:
/**
* param n: As description.
* return: A list of strings.
*/
vector<string> fizzBuzz(int n) {
vector<string> results;
for (int i = ; i <= n; i++) {
if (i % == ) {
results.push_back("fizz buzz");
} else if (i % == ) {
results.push_back("buzz");
} else if (i % == ) {
results.push_back("fizz");
} else {
results.push_back(to_string(i));
}
}
return results;
}
};
相关文章
- 02-02Leetcode 412. Fizz Buzz(DAY 137) ---- Leetcode 精选 TOP 面试题
- 02-02leetcode_412. Fizz Buzz
- 02-02LeetCode 412. Fizz Buzz
- 02-02[重构到模式-Chain of Responsibility Pattern]把Fizz Buzz招式重构到责任链模式
- 02-02Fizz Buzz
- 02-02(lintcode)第9题Fizz Buee问题
- 02-02LeetCode--412.Fizz Buzz(C++描述)
- 02-02[leetcode/lintcode 题解] 算法面试真题详解:Fizz Buzz 问题
- 02-02ERROR 1273 (HY000): Unknown collation: 'utf8mb4_0900_ai_ci' Query OK, 0 rows affected (0.00 sec) ERROR 11462S02): Table 'fizz_manager.blade_user' doesn't exist
- 02-02LintCode: Fizz Buzz