"Tom Scott" well mannered approach Java


#1

public class Solution {
public ArrayList fizzBuzz(int A) {

    ArrayList<String> res = new ArrayList<String>();
    
    
    for(int i=1;i<=A;i++){
        String str = "";
        
        if(i%3==0){
            str += "Fizz";
        }
        
        if(i%5==0){
            str += "Buzz";
        }
        
        if(str==""){
            str += i;
        }
        
        res.add(str);
    }
    
    return res;
    
}

}

> Blockquote