예제 #1
0
        private static void TestContainsDuplicate(int[] nums, int k, int t, bool expected)
        {
            var containsDuplicate = new ContainsDuplicateIII();
            var actual            = containsDuplicate.ContainsNearbyAlmostDuplicate(nums, k, t);

            Assert.AreEqual(expected, actual);
        }
예제 #2
0
        public void ShouldReturnFalseWhenTIsLessThan0()
        {
            var sol = new ContainsDuplicateIII();

            Assert.IsFalse(sol.ContainsNearbyAlmostDuplicate(new int[] { 1, 2 }, 1, -1));

            Assert.IsFalse(sol.ContainsNearbyAlmostDuplicate(new int[] { 1, 1 }, 1, -1));
        }
        public void Test1Bucket()
        {
            var sol = new ContainsDuplicateIII();

            Assert.AreEqual(false, sol.ContainsNearbyAlmostDuplicateBucket(new[] { 1, 5, 9, 1, 5, 9 }, 2, 3));
            Assert.AreEqual(true, sol.ContainsNearbyAlmostDuplicateBucket(new[] { 7, 1, 3 }, 2, 3));
            Assert.AreEqual(true, sol.ContainsNearbyAlmostDuplicateBucket(new[] { 1, 0, 1, 1 }, 1, 2));
        }
예제 #4
0
        public void ContainsNearbyAlmostDuplicateTest()
        {
            int[] nums     = { 1, 2, 3, 1 };
            int   k        = 3;
            int   t        = 0;
            bool  expected = true;
            bool  result   = new ContainsDuplicateIII().ContainsNearbyAlmostDuplicate(nums, k, t);

            Assert.AreEqual(expected, result);
        }
예제 #5
0
        public void ContainsNearbyAlmostDuplicateTest2()
        {
            int[] nums = { 1, 5, 9, 1, 5, 9 };
            int   k    = 2;
            int   t    = 3;

            bool expected = false;
            bool result   = new ContainsDuplicateIII().ContainsNearbyAlmostDuplicate(nums, k, t);

            Assert.AreEqual(expected, result);
        }
        public void ContainsNearbyAlmostDuplicateTests()
        {
            ContainsDuplicateIII obj = new ContainsDuplicateIII();

            // TODO:solution
        }
예제 #7
0
        public void ShouldReturnFalseWhenNullNums()
        {
            var sol = new ContainsDuplicateIII();

            Assert.IsFalse(sol.ContainsNearbyAlmostDuplicate(null, 1, 1));
        }
예제 #8
0
        public void Example5ShouldNotOverflow()
        {
            var sol = new ContainsDuplicateIII();

            Assert.IsFalse(sol.ContainsNearbyAlmostDuplicate(new int[] { -1, 2147483647 }, 1, 2147483647));
        }
예제 #9
0
        public void Example4ShouldReturnTrue()
        {
            var sol = new ContainsDuplicateIII();

            Assert.IsTrue(sol.ContainsNearbyAlmostDuplicate(new int[] { 3, 6, 0, 4 }, 2, 2));
        }
예제 #10
0
        public void Example3ShouldReturnFalse()
        {
            var sol = new ContainsDuplicateIII();

            Assert.IsFalse(sol.ContainsNearbyAlmostDuplicate(new int[] { 1, 5, 9, 1, 5, 9 }, 2, 3));
        }
예제 #11
0
        public void Example1ShouldReturnTrue()
        {
            var sol = new ContainsDuplicateIII();

            Assert.IsTrue(sol.ContainsNearbyAlmostDuplicate(new int[] { 1, 2, 3, 1 }, 3, 0));
        }
예제 #12
0
        private void ContainsDuplicateIIIUnitTestCase(int[] nums, int k, int t, bool expect)
        {
            var actual = ContainsDuplicateIII.ContainsDuplicate(nums, k, t);

            Assert.AreEqual(expect, actual);
        }