Beispiel #1
0
        public void GetMaxAreaTest()
        {
            int[] hist    = { 6, 2, 5, 4, 5, 1, 6 };
            int   maxArea = Batch1.GetMaxArea(hist);

            Assert.AreEqual(12, maxArea);

            int[] hist2 = { 1, 2, 3, 4, 5 };
            maxArea = Batch1.GetMaxArea(hist2);
            Assert.AreEqual(9, maxArea);
        }
Beispiel #2
0
        public void GenerateParentheseTest()
        {
            int numPar = 3;

            Batch1.GenerateParenthese(numPar);
            // expected the following results
            //      ((()))
            //      (()())
            //      (())()
            //      ()(())
            //      ()()()
        }
Beispiel #3
0
        public void LengthOfLongestSubstringTest()
        {
            string s = "abcddcba";
            int    len;

            len = Batch1.LengthOfLongestSubstring(s);
            Assert.AreEqual(4, len);

            s   = "abcdkmcbha";
            len = Batch1.LengthOfLongestSubstring(s);
            Assert.AreEqual(7, len);
        }
Beispiel #4
0
 public void NextPermutationTest()
 {
     int[] org       = { 5, 6, 9, 8, 5, 4, 4, 1 };
     int[] nextArray = Batch1.NextPermutation(org);
 }