Пример #1
0
        public void LongestCommonPrefix()
        {
            LongestCommonPrefixClass longestCommonPrefixClass = new LongestCommonPrefixClass();
            var result = longestCommonPrefixClass.LongestCommonPrefix(new[] { "earthly", "earth", "ear" });

            Assert.AreEqual(result, "ear");
        }
Пример #2
0
        public void LongestCommonPrefixTest()
        {
            var c = new LongestCommonPrefixClass();

            // example1
            string[] target   = { "dog", "racecar", "car" };
            var      result   = c.LongestCommonPrefix(target);
            var      expected = "";

            Assert.AreEqual(expected, result);

            // example2
            string[] target2 = { "flower", "flow", "flight" };
            result   = c.LongestCommonPrefix(target2);
            expected = "fl";
            Assert.AreEqual(expected, result);
        }