-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolution.cs
More file actions
25 lines (24 loc) · 775 Bytes
/
Solution.cs
File metadata and controls
25 lines (24 loc) · 775 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
namespace LeetCode.Problem2114{
//2114. Maximum Number of Words Found in Sentences
//https://leetcode.com/problems/maximum-number-of-words-found-in-sentences/
/*
A sentence is a list of words that are separated by a single space with no leading or trailing spaces.
You are given an array of strings sentences, where each sentences[i] represents a single sentence.
Return the maximum number of words that appear in a single sentence.
*/
public class Solution {
public int MostWordsFound(string[] sentences) {
return sentences
.Select(p=>
new {
List = p
.Split(' ')
.ToList()
.Count
})
.OrderByDescending(p=>p.List)
.FirstOrDefault()
.List;
}
}
}