Example #1
0
        public void LongestContinuousIncreasingSubsequenceTestMethod()
        {
            var longestContinuousIncreasingSubsequence = new LongestContinuousIncreasingSubsequence();
            var input1    = new int[] { 1, 3, 5, 4, 7 };
            var expected1 = 3;
            var actual1   = longestContinuousIncreasingSubsequence.FindLengthOfLCIS(input1);

            Assert.AreEqual(expected1, actual1);

            var input2    = new int[] { 2, 2, 2, 2, 2 };
            var expected2 = 1;
            var actual2   = longestContinuousIncreasingSubsequence.FindLengthOfLCIS(input2);

            Assert.AreEqual(expected2, actual2);
        }
        public void GenerateMatrixTests()
        {
            LongestContinuousIncreasingSubsequence obj = new LongestContinuousIncreasingSubsequence();

            int[] nums = new[] { 1, 3, 5, 4, 7 };
            var   x    = obj.FindLengthOfLCIS(nums); //3

            nums = new[] { 2, 2, 2, 2, 2 };          //1
            x    = obj.FindLengthOfLCIS(nums);

            nums = new int[] {  };             //
            x    = obj.FindLengthOfLCIS(nums); //0

            nums = new int[] { 1 };            //
            x    = obj.FindLengthOfLCIS(nums); //1


            nums = new int[] { 1, 3, 5, 4, 2, 3, 4, 5 }; //
            x    = obj.FindLengthOfLCIS(nums);           //1
        }