@@ -0,0 +1,1485 @@
+package array;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0Apublic class FizzBuzz %7B%0A%0A    //Difficulty: Easy%0A    //TAG: Apple%0A    //TAG: array%0A    //TAG: math%0A%0A    /**%0A     * 412. Fizz Buzz%0A     * Write a program that outputs the string representation of numbers from 1 to n.%0A     *%0A     * But for multiples of three it should output %E2%80%9CFizz%E2%80%9D instead of the number and for the multiples of five output %E2%80%9CBuzz%E2%80%9D. For numbers which are multiples of both three and five output %E2%80%9Carray.FizzBuzz%E2%80%9D.%0A     *%0A     * Example:%0A     *%0A     * n = 15,%0A     *%0A     * Return:%0A     * %5B%0A     *     %221%22,%0A     *     %222%22,%0A     *     %22Fizz%22,%0A     *     %224%22,%0A     *     %22Buzz%22,%0A     *     %22Fizz%22,%0A     *     %227%22,%0A     *     %228%22,%0A     *     %22Fizz%22,%0A     *     %22Buzz%22,%0A     *     %2211%22,%0A     *     %22Fizz%22,%0A     *     %2213%22,%0A     *     %2214%22,%0A     *     %22array.FizzBuzz%22%0A     * %5D%0A     */%0A%0A    /*%0A    Solution:%0A    Fist check array.FizzBuzz due to check both first will reduce check afterwards%0A%0A    Time: O(n)%0A    Space: O(n)%0A     */%0A%0A    public List%3CString%3E fizzBuzz(int n) %7B%0A        List%3CString%3E list = new ArrayList%3C%3E();%0A        for (int i = 1; i %3C= n; i++) %7B%0A            if (i %25 3 == 0 && i %25 5 == 0) %7B%0A                list.add(%22array.FizzBuzz%22);%0A            %7D else if (i %25 3 == 0) %7B%0A                list.add(%22Fizz%22);%0A            %7D else if (i %25 5 == 0) %7B%0A                list.add(%22Buzz%22);%0A            %7D else %7B%0A                list.add(String.valueOf(i));%0A            %7D%0A        %7D%0A        return list;%0A    %7D%0A%0A%7D%0A

412. Fizz Buzz