
									 Problem
								
								
									 Solution
								
								
									 Submissions
								
								
							Fizz Buzz
								Certification: Basic Level
								Accuracy: 16.67%
								Submissions: 6
								Points: 5
							
							Write a C program that prints the numbers from 1 to n. But for multiples of three, print "Fizz" instead of the number, and for the multiples of five, print "Buzz". For numbers which are multiples of both three and five, print "FizzBuzz". The function should return an array of strings containing the appropriate responses.
Example 1
- Input: n = 15
- Output: ["1","2","Fizz","4","Buzz","Fizz","7","8","Fizz","Buzz","11","Fizz","13","14","FizzBuzz"]
- Explanation: For multiples of 3 (3, 6, 9, 12), we print "Fizz". For multiples of 5 (5, 10), we print "Buzz". For multiples of both 3 and 5 (15), we print "FizzBuzz". For all other numbers, we print the number itself.
Example 2
- Input: n = 8
- Output: ["1","2","Fizz","4","Buzz","Fizz","7","8"]
- Explanation: For multiples of 3 (3, 6), we print "Fizz". For multiples of 5 (5), we print "Buzz". There are no multiples of both 3 and 5 in this range. For all other numbers, we print the number itself.
Constraints
- 1 ≤ n ≤ 10^4
- You need to allocate memory for the result array
- Time Complexity: O(n)
- Space Complexity: O(n) for the result array
Editorial
									
												
My Submissions
										All Solutions
									| Lang | Status | Date | Code | 
|---|---|---|---|
| You do not have any submissions for this problem. | |||
| User | Lang | Status | Date | Code | 
|---|---|---|---|---|
| No submissions found. | ||||
Solution Hints
- Create an array of strings to store the result
- Iterate from 1 to n
- For each number, check if it's divisible by 3, 5, or both
- Append the appropriate string to the result array
- Remember to properly allocate and free memory for each string in the array
