Exemplo n.º 1
0
        static void Main(string[] args)
        {
            int  numberOfInstructions = Convert.ToInt32(Console.ReadLine());
            Trie trie = new Trie();

            for (int index_instruction = 0; index_instruction < numberOfInstructions; index_instruction++)
            {
                string[] tokens_op = Console.ReadLine().Split(' ');
                string   op        = tokens_op[0];
                string   contact   = tokens_op[1];
                switch (op)
                {
                case "add":
                    trie.Add(contact);
                    break;

                case "find":
                    Console.WriteLine(trie.CountAllStartsWith(contact));
                    break;
                }
            }
        }