using System.Collections.Generic;
public Dictionary<char, ListNode> Edges = new();
private ListNode head = new();
private void AddWord(string word, ListNode node)
var wordChars = word.ToCharArray();
if(!node.Edges.ContainsKey(c))
AddWord(new string(wordChars.Skip(1).ToArray()), node.Edges[c]);
if(!node.Edges.ContainsKey('*'))
AddWord(new string(wordChars.Skip(1).ToArray()), node.Edges[c]);
public MyDictionary(IEnumerable<string> wordList)
foreach(var word in wordList)
public bool IsInDict(string word)
public void Print(ListNode node = null)
foreach(var key in head.Edges.Keys)
public static void Main()
MyDictionary myDict = new(new string[] { "dog", "cat" });