Easy and efficient c++ solution


#1

vector Solution::fizzBuzz(int A) {
vector sol(A);
for(int i=1; i<A+1; i++){
string add;
bool check=true;
//string s1, s2;
if(i%3 ==0){
add.append(“Fizz”);
check=false;
}
if(i%5 ==0){
add.append(“Buzz”);
check=false;
}
if(check){
string s = to_string(i);
sol[i-1] = s;
} else {
sol[i-1] = add;
}
}
return sol;
}