One-line c# solution


  • 9
    M
    public class Solution {
        public IList<string> FizzBuzz(int n) {
            return Enumerable.Range(1,n).Select(i => i % 15 == 0 ? "FizzBuzz" : i % 3 == 0 ? "Fizz" : i % 5 == 0 ? "Buzz" : i.ToString()).ToList();
        }   
    }

  • 0
    S

    That's great!


Log in to reply
 

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