Exemplo n.º 1
0
        public IList <string> RemoveSubfolders(string[] folder)
        {
            IList <string> result = new List <string>();
            TrieT          root   = new TrieT();

            foreach (var fo in folder)
            {
                string[] path = fo.Split('/');
                TrieT    cur  = root;
                foreach (var p in path)
                {
                    if (p == "")
                    {
                        continue;
                    }
                    if (!cur.Child.ContainsKey(p))
                    {
                        cur.Child.Add(p, new TrieT());
                    }
                    cur = cur.Child[p];
                }
                cur.IsRoot = true;
            }
            GetFolder(root, result, "");
            return(result);
        }
Exemplo n.º 2
0
 public void GetFolder(TrieT root, IList <string> result, string cur)
 {
     if (root.IsRoot)
     {
         result.Add(cur);
         return;
     }
     foreach (var pair in root.Child)
     {
         GetFolder(pair.Value, result, cur + "/" + pair.Key);
     }
 }