Fastest solution with mod operator


#1

Comment body goes here.**]

public class Solution {
public ArrayList<String> fizzBuzz(int n) {
    ArrayList<String> s = new ArrayList<>();
    
    int c3 = 0;
    int c5 = 0;
    for(int i = 1;i<=n;i++){
       c3++;
       c5++;
         String d = "";
       if(c3 == 3){
           d += "Fizz";
           //s.add(d);
           c3 = 0;
       }if(c5 == 5){
           d += "Buzz";
           //s.add(d);
           c5 = 0;
           
       }if(d == ""){
        
           s.add(Integer.toString(i));
       }else{
           s.add(d);
       }
    }
    return s;
}

}

**