Exemplo n.º 1
0
        public void RunProblem()
        {
            var dic = new MagicDictionary();

            dic.BuildDict(new string[] { "hello", "leetcode" });

            var temp = dic.Search("hello");

            if (temp != false)
            {
                throw new Exception();
            }

            temp = dic.Search("hhllo");
            if (temp != true)
            {
                throw new Exception();
            }

            temp = dic.Search("hell");
            if (temp != false)
            {
                throw new Exception();
            }

            temp = dic.Search("leetcoded");
            if (temp != false)
            {
                throw new Exception();
            }
        }
Exemplo n.º 2
0
        public void SearchTest1()
        {
            var test = new MagicDictionary();

            test.BuildDict(new string[] { "hello", "hallo", "leetcode" });
            Assert.IsTrue(test.Search("hello"));
            Assert.IsTrue(test.Search("hhllo"));
            Assert.IsFalse(test.Search("hell"));
            Assert.IsFalse(test.Search("leetcoded"));
        }
Exemplo n.º 3
0
        public static void Main()
        {
            MagicDictionary solution = new MagicDictionary();

            solution.BuildDict(new[] { "h", "hh", "hal", "hello", "welly", "leetcode" });

            Test.Check(solution.Search, "hell", false);
            Test.Check(solution.Search, "hello", false);
            Test.Check(solution.Search, "hellow", false);

            Test.Check(solution.Search, "gello", true);
            Test.Check(solution.Search, "hhllo", true);
            Test.Check(solution.Search, "heplo", true);
            Test.Check(solution.Search, "helpo", true);
            Test.Check(solution.Search, "hellz", true);

            Test.Check(solution.Search, "hhllz", false);

            Test.Check(solution.Search, "leetcode", false);
            Test.Check(solution.Search, "leetcodz", true);
            Test.Check(solution.Search, "leetcade", true);
            Test.Check(solution.Search, "le3tcode", true);
            Test.Check(solution.Search, "lootcode", false);
        }