1002. Find Common Characters
找共通字串
Example 1:
Input: words = ["bella","label","roller"]
Output: ["e","l","l"]
想法: 沒有,就硬幹
C# code:
public class Solution
{
public IList<string> CommonChars(string[] words)
{
var count = new int[26];
for (int i = 0; i < count.Length; i++)
{
count[i] = words[0].Count(x => x == 'a' + i);
for (int j = 1; j < words.Length; j++)
{
if (count[i] == 0) break;
count[i] = Math.Min(count[i], words[j].Count(x => x == 'a' + i));
}
}
var result = new List<string>();
for (int i=0; i<count.Length; i++)
{
while (count[i] != 0)
{
result.Add(((char)('a' + i)).ToString());
count[i]