<p>Given an integer <code>n</code>, return <em>a string array </em><code>answer</code><em> (<strong>1-indexed</strong>) where</em>:</p>

<ul>
	<li><code>answer[i] == &quot;FizzBuzz&quot;</code> if <code>i</code> is divisible by <code>3</code> and <code>5</code>.</li>
	<li><code>answer[i] == &quot;Fizz&quot;</code> if <code>i</code> is divisible by <code>3</code>.</li>
	<li><code>answer[i] == &quot;Buzz&quot;</code> if <code>i</code> is divisible by <code>5</code>.</li>
	<li><code>answer[i] == i</code> (as a string) if none of the above conditions are true.</li>
</ul>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<pre><strong>Input:</strong> n = 3
<strong>Output:</strong> ["1","2","Fizz"]
</pre><p><strong class="example">Example 2:</strong></p>
<pre><strong>Input:</strong> n = 5
<strong>Output:</strong> ["1","2","Fizz","4","Buzz"]
</pre><p><strong class="example">Example 3:</strong></p>
<pre><strong>Input:</strong> n = 15
<strong>Output:</strong> ["1","2","Fizz","4","Buzz","Fizz","7","8","Fizz","Buzz","11","Fizz","13","14","FizzBuzz"]
</pre>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= n &lt;= 10<sup>4</sup></code></li>
</ul>

class Solution {
 public:
  std::vector<std::string> fizzBuzz(int n) {
    std::vector<std::string> str_vec(n);

    const std::string fizz("Fizz");
    const std::string buzz("Buzz");

    for (auto i = 0; i < n; i++) {
      char out_buffer[6];
      auto& cur_str = str_vec[i];
      cur_str.reserve(6);

      auto ret = (i + 1);
      auto div_by_3 = ((ret % 3) == 0);

      if (div_by_3) {
        cur_str = fizz;
      }

      auto div_by_5 = ((ret % 5) == 0);

      if (div_by_5) {
        cur_str.append("Buzz");
      } else {
        if (!div_by_3) {
          cur_str.resize(6);
          auto char_count = sprintf(&cur_str[0] ,"%d", ret);

          cur_str.resize(char_count);
        }
      }
    }

    return str_vec;
  }
};
9700