Efficient Solution in CPP with detailed stepwise explanation|| Beginner-Friendly
Intuition\nTo make a vector and return the desired output.\n\n# Approach\n1. Create an empty vector v to store the FizzBuzz results.\n\n2. Check if n is equal t
# Intuition\nTo make a vector and return the desired output.\n\n# Approach\n1. Create an empty vector `v` to store the FizzBuzz results.\n\n2. Check if `n` is equal to 1. If it is, add "1" as a string to the vector `v` using `v.push_back(to_string(1))`.\n\n3. If `n` is greater than 1, initialize the vector `v` with the first two elements: "1" and "2". This is because these numbers are not divisible by 3 or 5 and don\'t require FizzBuzz replacements.\n\n4. Start a loop from `i = 3` to `i <= n`.\n\n5. Inside the loop, check if `i` is divisible by both 3 and 5. If it is, add "FizzBuzz" to the vector `v` using `v.push_back("FizzBuzz")`.\n\n6. If `i` is not divisible by both 3 and 5, check if it is divisible by 5 only. If it is, add "Buzz" to the vector `v` using `v.push_back("Buzz")`.\n\n7. If `i` is not divisible by both 3 and 5, check if it is divisible by 3 only. If it is, add "Fizz" to the vector `v` using `v.push_back("Fizz")`.\n\n8. If none of the above conditions are met, it means that `i` is not divisible by 3 or 5. Convert `i` to a string using `to_string(i)` and add it to the vector `v` using `v.push_back(to_string(i))`.\n\n9. After the loop ends, return the vector `v` containing the FizzBuzz sequence.\n\n\n# Complexity\n- Time complexity:\n O(n)\n\n- Space complexity:\n O(n)\n\n# Code\n```\nclass Solution {\npublic:\n    vector<string> fizzBuzz(int n) {\n      vector<string>v;\n      if(n==1) v.push_back(to_string(1));\n      else{\n            v.push_back(to_string(1));\n            v.push_back(to_string(2));\n            for(int i=3;i<=n;i++)\n                {\n                if(i%3==0 && i%5==0) v.push_back("FizzBuzz");\n                else if(i%5==0) v.push_back("Buzz");\n                else if(i%3==0) v.push_back("Fizz");\n                else{\n                    v.push_back(to_string(i));\n                    }\n                }\n        } \n            return v; \n    }\n};\n```\nPlese upvote for better reach!!
['C++']