# FizzBuzz | InterviewBit | LeetCode | Solution in Python3, C++

FizzBuzz is a simple Interview problem. I present the solutions in Python3 and C++. IB Problem Link. LC Problem Link.

```class Solution:
def fizzBuzz(self, A):
ans = []
for x in range(1, A+1):
temp = ""
if x % 3 == 0: temp += "Fizz"
if x % 5 == 0: temp += "Buzz"
if not len(temp): temp = str(x)
ans.append(temp)
return ans
```
```vector<string> Solution::fizzBuzz(int A) {
vector <string> ans;
for (int i = 1; i <= A; i++) {
string temp = "";

if (i % 3 == 0) temp += "Fizz";
if (i % 5 == 0) temp += "Buzz";
if (!temp.length()) temp = to_string(i);

ans.push_back(temp);
}

return ans;
}
```
##### Tanishq Chaudhary Producing high-quality intuitive explanations of interview problems. Currently covering LeetCode and InterviewBit.

### Recommended Posts

##### Gas Station | InterviewBit | Solution Explained

June 13, 2022

##### Majority Element | InterviewBit | Solution Explained

June 13, 2022

##### Assign Mice to Holes | InterviewBit | Solution Explained

June 13, 2022

1. Srishti Chopra :July 23, 2022 at 11:29 am
2. Makarand :August 16, 2022 at 11:06 am