Skip to content

Latest commit

 

History

History
18 lines (17 loc) · 421 Bytes

412. Fizz Buzz.md

File metadata and controls

18 lines (17 loc) · 421 Bytes
class Solution {
public:
    vector<string> fizzBuzz(int n) {
        vector<string> ret(n);
        for (int i = 1; i <= n; ++i) 
            ret[i - 1] = to_string(i);
        for (int i = 2; i < n; i += 3)
            ret[i] = "Fizz";
        for (int i = 4; i < n; i += 5)
            ret[i] = "Buzz";
        for (int i = 14; i < n; i += 15)
            ret[i] = "FizzBuzz";
        return ret;
    }
};