C# one line of code


  • 0
    A

    C# one line of code

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

    }


Log in to reply
 

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