Fizz Buzz LeetCode solution in C++
1class Solution {2public:3vector<string> fizzBuzz(int n) {4vector<string> ans;5string hehe;6for (int i = 1; i <= n; i++) {7if (i % 3 == 0 and i % 5 == 0)8hehe += "FizzBuzz";9else if (i % 3 == 0)10hehe += "Fizz";11else if (i % 5 == 0)12hehe += "Buzz";13else14hehe = to_string(i);15ans.push_back(hehe);16hehe = "";17}18return ans;19}20};