Пример #1
0
        public void LengthOfLongestSubstringTest3()
        {
            LongestSubstring longestSubstring = new LongestSubstring();
            int res = longestSubstring.LengthOfLongestSubstring("pwwkew");

            Assert.IsTrue(res == 3);
        }
Пример #2
0
        public void LengthOfLongestSubstringTest4()
        {
            LongestSubstring longestSubstring = new LongestSubstring();
            int res = longestSubstring.LengthOfLongestSubstring("");

            Assert.IsTrue(res == 0);
        }
Пример #3
0
        public void LengthOfLongestSubstringTest1()
        {
            LongestSubstring longestSubstring = new LongestSubstring();
            int res = longestSubstring.LengthOfLongestSubstring("abcabcbb");

            Assert.IsTrue(res == 3);
        }
Пример #4
0
        static void Main(string[] args)
        {
            Console.WriteLine(LongestSubstring.findLongestSubStringK(3, "cbbebi"));

            Console.WriteLine(LongestSubstring.MaxFruitCountOf2Types(new char[] { 'A', 'B', 'C', 'B', 'B', 'C' }));

            Console.ReadLine();
        }
Пример #5
0
        private void MyEntryCompleted(object sender, EventArgs e)
        {
            InputLabel.Text = myEntry.Text;
            string myString = myEntry.Text;

            OutputLabel.Text = LongestSubstring.FindSubSting(ref myString);

            myEntry.Text = null;
        }
Пример #6
0
        public void LongestSubstring()
        {
            LongestSubstring ls = new LongestSubstring();

            Assert.Equal("CDGH", ls.Find("ABCDGH", "ACDGHR"));
            Assert.Equal("CDGH", ls.Find("ABCDGH", "ABRCDGH"));
            Assert.Equal("A", ls.Find("ABC", "AC"));
            Assert.Equal("", ls.Find("A", "B"));
        }
Пример #7
0
        /// <summary>
        /// 알고리즘 테스트용 콘솔
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            for (; ;)
            {
                string myString = Console.ReadLine();

                Console.WriteLine(LongestSubstring.FindSubSting(ref myString));

                Console.Write('\n');

                Console.ReadKey();
            }
        }
        public void LengthOfLongestSubstring_ShouldReturn_LengthOfLongestNonRepeatedSubstring(
            string s,
            int expectedMaximumLength)
        {
            // Arrange
            var longestSubstring = new LongestSubstring();

            // Act
            var maximumLength = longestSubstring.LengthOfLongestSubstring(s);

            // Assert
            maximumLength.Should().Be(expectedMaximumLength);
        }
Пример #9
0
        public void LongestSubstringSlidingWindowSuccess()
        {
            string input = "abcabcbb";
            int    result;

            result = new LongestSubstring().LengthOfLongestSubstringSlidingWindow(input);
            Assert.AreEqual(result, 3);

            input  = "pwwkew";
            result = new LongestSubstring().LengthOfLongestSubstringSlidingWindow(input);
            Assert.AreEqual(result, 3);

            input  = "bbbbbb";
            result = new LongestSubstring().LengthOfLongestSubstringSlidingWindow(input);
            Assert.AreEqual(result, 1);
        }
Пример #10
0
        void InternalTest(string s, int expected)
        {
            int count = LongestSubstring.LengthOfLongestSubstring(s);

            Assert.Equal <int>(expected, count);
        }
Пример #11
0
        private static void ExistingCases()
        {
            Console.WriteLine("This is DB practice session..");
            Console.WriteLine("Press 1 for Binary search tree");
            Console.WriteLine("Press 2 for two sum problem");
            Console.WriteLine("Press 3 for Maximum Area Cake problem");
            Console.WriteLine("Press 4 for Find Inflection point.");
            Console.WriteLine("Press 5 for Max heap.");
            Console.WriteLine("Press 6 for Longest substring.");
            Console.WriteLine("Press 7 for Reverse linked list.");
            Console.WriteLine("Press 8 for Reverse linked list.");

            int option = 5;

            switch (option)
            {
            case 1:
                BinarySearchOperations();
                break;

            case 2:
                RandomProblems.TwoSumProblem();
                break;

            case 3:
                MaximumAreaCake.MaximumAreaCakeCaller();
                break;

            case 4:
                CodeFindInflectionPoint.FindInflectionPoint();
                break;

            case 5:
                MaxHeap.Test();
                break;

            case 6:
                LongestSubstring.Test();
                break;

            case 7:
                ReverseListSolution.Test();
                break;

            case 8:
                SlidingWindows.Test();
                break;

            case 9:
                SlowAndFastPointers.Tests();
                break;

            case 10:
                CyclicSort.Tests();
                break;

            case 11:
                FastAndSlowPointers.Tests();
                break;

            case 12:
                MergeIntervals.Tests();
                break;

            default:
                break;
            }
        }
Пример #12
0
 public LongestSubstringTests()
 {
     _testsVerifier = new TestsVerifier();
     _objUnderTest  = new LongestSubstring();
 }
Пример #13
0
        public void LengthOfLongestSubstringTest(string s, int expected)
        {
            var sut = new LongestSubstring();

            Assert.Equal(expected, sut.LengthOfLongestSubstring(s));
        }
 public void Setup()
 {
     _sut = new LongestSubstring();
 }