Simple Solution
Intuition\nThe FizzBuzz problem is a classic programming exercise where you need to iterate through numbers from 1 to n and perform certain actions based on div
# Intuition\nThe FizzBuzz problem is a classic programming exercise where you need to iterate through numbers from 1 to n and perform certain actions based on divisibility rules. Specifically, for each number:\n\nIf it\'s divisible by 3, replace it with "Fizz."\nIf it\'s divisible by 5, replace it with "Buzz."\nIf it\'s divisible by both 3 and 5, replace it with "FizzBuzz."\nOtherwise, keep the number as is.\n\n# Approach\n1. Initialize an empty list result to store the FizzBuzz output.\n2. Iterate through the numbers from 1 to n using a for loop.\n3. For each number i in the loop:\n    - Check if i is divisible by 3 and 5. If it is, append "FizzBuzz" to the result list.\n    - Otherwise, check if i is divisible by 3. If it is, append "Fizz" to the result list.\n    - Otherwise, check if i is divisible by 5. If it is, append "Buzz" to the result list.\n    - If none of the above conditions are met, convert i to a string using str(i) and append it to the result list.\n4. After the loop completes, the result list will contain the FizzBuzz output for numbers from 1 to n.\nReturn the result list as the final answer.\n\n# Complexity\n- Time complexity:\nThe time complexity of this solution is O(n) because we iterate through numbers from 1 to n once, and for each number, we perform constant time operations (divisions and comparisons).\n- Space complexity:\nThe space complexity is also O(n) because the result list stores the FizzBuzz strings for all numbers from 1 to n. The space required is linearly proportional to the input size.\n\n# Code\n```\nclass Solution {\npublic:\n    vector<string> fizzBuzz(int n) {\n        vector<string> v;\n        for(int i=1;i<n+1;i++){\n            if (i%3 == 0 && i%5 == 0){\n                v.push_back("FizzBuzz");\n            }\n            else if (i%3 == 0){\n                v.push_back("Fizz");\n            }\n            else if (i%5 == 0){\n                v.push_back("Buzz");\n            }\n            else{\n                v.push_back(to_string(i));\n            }\n        }\n        return v;\n    }\n};\n```
['C++']