Skip to content

Missing Test Case - 412. Fizz Buzz #32197

@rakeshpedapudi07

Description

@rakeshpedapudi07

LeetCode Username

rakesh_pedapudi

Problem Number, Title, and Link

https://leetcode.com/problems/fizz-buzz/

Bug Category

Missing test case (Incorrect/Inefficient Code getting accepted because of missing test cases)

Bug Description

The current test cases do not cover numbers just beyond a multiple of 15. For example, numbers like 16 are not included in existing test cases to ensure proper output as a string when they are not divisible by 3 or 5.

Language Used for Code

Java

Code used for Submit/Run operation

import java.util.*;

class Solution{
    public List<String> fizzBuzz(int n){
        List<String> res = new ArrayList<>();
        for(int i=1; i<=n; i++){
            if(i % 15==0){ 
                res.add("FizzBuzz");
            }else if(i % 3==0){ 
                res.add("Fizz");
            }else if(i % 5==0){ 
                res.add("Buzz");
            }else{  
                res.add(String.valueOf(i));
            }
        }
        return res;
    }
}

Expected behavior

For input n = 16, the expected output should be:
["1","2","Fizz","4","Buzz","Fizz","7","8","Fizz","Buzz","11","Fizz","13","14","FizzBuzz","16"]

This ensures that numbers beyond a multiple of 15 are correctly handled.

Screenshots

Not applicable

Additional context

This test case ensures that the solution correctly handles numbers that are not divisible by 3 or 5 after a FizzBuzz cycle, which is currently missing from the problem's test cases.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions