public TrieNode(TrieNode parent, char c) { m_char = c; m_word_count = 0; m_parent = parent; m_children = new ConcurrentDictionary<char, TrieNode>(); }
static void Main(string[] args) { // maximumsizeSubmatrix(); // largestRectangleSize(); // string[] str1= str(); Console.Write(new Interface1.callme().get()); VMWAre vmobj = new VMWAre(); int[] A={5,1,4,3}; int[] b = { 2,3,5,1,4}; //vmobj.permute(ref A,1,4); vmobj.vmQuestion(b); String strInput="the cat can catch the mouse"; TrieNode root = new TrieNode(null, '?'); string[] chunks = strInput.Split(null); foreach (string chunk in chunks) { root.AddWord(chunk.Trim()); } Dictionary<string, int> lststring = new Dictionary<string,int>(); root.GetAllWordCount(root,ref lststring, string.Empty); // Use OrderBy method. foreach (var item in lststring.OrderBy(l => l.Value)) { Console.WriteLine(item); } var items = from pair in lststring orderby pair.Value descending select pair; dicegame(new string[]{ "4","137","364","115","724" }); // NumberOfPairs(new int[]{6,6,3,9,3,5,1},12); /* an array with 5 rows and 2 columns*/ int[,] a = new int[5, 2] { { 0, 0 }, { 1, 2 }, { 2, 4 }, { 3, 6 }, { 4, 8 } }; int i, j; /* output each array element's value */ for (i = 0; i < 5; i++) { for (j = 0; j < 2; j++) { Console.WriteLine("a[{0},{1}] = {2}", i, j, a[i, j]); } } Console.ReadKey(); }
public void GetAllWordCount(TrieNode ParenNode,ref Dictionary<String,int> lst,string word) { foreach(KeyValuePair<char,TrieNode> childnode in ParenNode.m_children) { if(childnode.Value.m_children.Count == 0) { lst.Add(word + childnode.Key.ToString(), childnode.Value.m_word_count); } else { GetAllWordCount(childnode.Value, ref lst, word+childnode.Key.ToString()); } } }