Java One-liner in case anyone is interested.


  • 0
    J
        public List<String> fizzBuzz(int n) {
            return IntStream.range(1, n+1).mapToObj(i -> i % 15 == 0 ? "FizzBuzz" : i % 5 == 0 ? "Buzz" : i % 3 == 0 ? "Fizz" : "" + i).collect(Collectors.toList());
        }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.