Question: Using C# I'm trying to find a specific word within a char array. Also, I don't want the same letter used more than once i.e. the word is 'hello' and I'm trying to find it within a random array of letters, so if the letter 'l' is used out of the random array of letters, I don't want it to be used again. There should be another 'l' within the array of letters to be used as the second 'l' in "hello". Just trying to be precise. A simple answer would be very helpful. Thank you.

Here is my attempt so far. 

```
public static char [] Note = "hello".ToCharArray();
public static char [] Newspaper = "ahrenlxlpoz".ToCharArray();

static void main(string[] args)
{
    Array.Sort(Note);
    Array.Sort(Newspaper);

    if(Newspaper.Contains<Note>)
    {
        Console.Write("It should display the letters of Note found within Newspaper");
    }   
}

```

Answer: 
I assume by "contains" you mean Newspaper has enough number of letters from each letter to make up Note. For example, you need at least two l's to make up the word "hello". If so, you need to basically count the number of each letter in both strings, and make sure the number of each letter in Note is less than or equal to the number of that letter in Newspaper.

```
var dictNote = Note.GroupBy(c => c).ToDictionary(g => g.Key, g => g.Count());
var dictNews = Newspaper.GroupBy(c => c).ToDictionary(g => g.Key, g => g.Count());

bool contains = dictNote.All(x => 
    dictNews.ContainsKey(x.Key) && x.Value <= dictNews[x.Key]);

```
Try this:

```
public static char[] Note = "hello".ToCharArray();
public static char[] Newspaper = "ahrenlxlpoz".ToCharArray();

foreach (char c in Note) //check each character of Note
{
    if (Newspaper.Contains(c))
    {
        Console.Write(c); //it will display hello
    }
}

```