C# Solution with Linq and Split()


  • 0
    N
    public class Solution
    {
        public int CountSegments(string s)
        {
            return s.Split(' ').Count(x => x != String.Empty);
        }
    }
    

Log in to reply
 

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