SRM 453.5 DIV2 Level.1

Stringの配列が与えられて、その中で重複ぬかして単語が何個あるか数える問題。

using System;
using System.Collections.Generic;
using System.Text;

public class ToolsBox
{
    public int countTools(String[] need)
    {
        int count = 0;
        Dictionary<String, int> dic = new Dictionary<string, int>();

        foreach (String s in need)
        {
            String[] split = s.Split(' ');
            foreach (String s2 in split)
            {
                if (!dic.ContainsKey(s2))
                {
                    count++;
                    dic[s2] = 1;
                }
            }
        }
        return count;
    }
}