Concise Extensible Java Solution by using Map (NO IF - ELSE)
One caveat is that people should not think easy question is actually easy.  In a lot of the cases in a real world interview it\'s not about OJ accepting your so
One caveat is that people should `not think easy question is actually easy`.  In a lot of the cases in a real world interview it\'s not about OJ accepting your solution. It\'s more about how you could think thoroughly about a `seemly easy case`. `Assume Nothing` should be your attitude walking into an interview room. \n\nDid u clarify the input? Discuss whether n could be `negative` or `0`? Discuss all of the test cases? edge cases? what is the possible range of the given number `n`, is `int` enough or maybe `long` is better?  Could `n` be `super huge like trillions of trillions` that the result couldn\'t fit into memory? We need to pay attention to this sort of mental exercises for every single problem we practice to really train our algorithmic thinking ability.\n\nWhat about if the interviewer asks about how you could make your code more extensible by adding more rules?  The following might be a good answer to that.\n```\n    public List<String> fizzBuzz(int n) {\n        if (n <= 0) {\n            return new ArrayList();\n        }\n        TreeMap<Integer, String> map = new TreeMap<>((a, b) -> a - b); // define the order of how you want to concat the words here using lambda comparator\n        map.put(3, "Fizz");\n        map.put(5, "Buzz");\n        // map.put(7, "Yuzz"); \n        // map.put(9, "Mozz"); add more encoding options here ... \n        List<String> numsStrs = new LinkedList();\n        for (int i = 1; i <= n; i++) { \n            StringBuilder encoded = new StringBuilder();\n            for (int num : map.keySet()) {\n                if (i % num == 0) encoded.append(map.get(num));\n            }\n            numsStrs.add((encoded.length() == 0) ? String.valueOf(i) : encoded.toString());\n        }\n        return numsStrs;\n    }\n```
[]