public void Add(string word) { Count++; if (word == string.Empty) { _section['0'] = NullTrie; return; } var key = word.Length > 0 ? word.Last() : '0'; if (!_section.ContainsKey(key)) { _section[key] = new EndTrie(); } _section[key].Add(word.Substring(0, word.Length - 1)); }
static void _Main(string[] args) { var t = int.Parse(Console.ReadLine()); var k = 1; while (k <= t) { var n = int.Parse(Console.ReadLine()); var wordsTrie = new EndTrie(); for (int i = 0; i < n; i++) { wordsTrie.Add(Console.ReadLine()); } var answer = wordsTrie.PairOffAndRemove() * 2; Console.WriteLine($"Case #{k}: {answer}"); k++; } }