Skip to content

Latest commit

 

History

History
24 lines (21 loc) · 563 Bytes

412. Fizz Buzz.md

File metadata and controls

24 lines (21 loc) · 563 Bytes

412. Fizz Buzz

Fizz Buzz - LeetCode

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