public void TestMethod1(int[] nums, int k, bool expected)
        {
            // Arrange
            ContainsDuplicateII question = new ContainsDuplicateII();

            // Act
            bool actual = question.ContainsNearbyDuplicate(nums, k);

            // Assert
            Assert.AreEqual(expected, actual);
        }
Esempio n. 2
0
        public void ContainsNearbyDuplicateTests()
        {
            ContainsDuplicateII obj = new ContainsDuplicateII();

            // MODIFY: use   Dictionary<int, int> and always save only the last iterated index and compare with compare with current Index as this would the lowest possible difference
            //        var nums = new int[] { 1, 2, 3, 1 };
            //        int k = 3;
            //        var resp = ContainsNearbyDuplicate(nums, k);
            //        //Output: true

            //        nums = new int[] { 1, 0, 1, 1 };
            //    k = 1;
            //            resp = ContainsNearbyDuplicate(nums, k);
            //    //Output: true

            //    nums = new int[] { 1, 2, 3, 1, 2, 3 };
            //k = 2;
            //            resp = ContainsNearbyDuplicate(nums, k);
            ////Output: false
        }
Esempio n. 3
0
        public bool SampleTests(int[] input, int k)
        {
            var kata = new ContainsDuplicateII();

            return(kata.ContainsNearbyDuplicate(input, k));
        }
Esempio n. 4
0
 public void BeforeEach()
 {
     ContainsDuplicateII = new ContainsDuplicateII();
 }