Commit 1b046ad
Changed files (1)
spec/contains_close_numbers_spec.rb
@@ -0,0 +1,39 @@
+<<-DOC
+Given an array of integers nums and an integer k,
+determine whether there are two distinct indices i and j
+in the array where nums[i] = nums[j] and the
+absolute difference between i and j is less than or equal to k.
+
+Example
+
+For nums = [0, 1, 2, 3, 5, 2] and k = 3, the output should be
+containsCloseNums(nums, k) = true.
+
+There are two 2s in nums, and the absolute difference between their positions is exactly 3.
+
+For nums = [0, 1, 2, 3, 5, 2] and k = 2, the output should be
+
+containsCloseNums(nums, k) = false.
+
+The absolute difference between the positions of the two 2s is 3, which is more than k.
+
+Input/Output
+
+[time limit] 4000ms (rb)
+[input] array.integer nums
+
+Guaranteed constraints:
+0 ≤ nums.length ≤ 55000,
+-231 - 1 ≤ nums[i] ≤ 231 - 1.
+
+[input] integer k
+
+Guaranteed constraints:
+0 ≤ k ≤ 35000.
+
+[output] boolean
+DOC
+
+describe "#contains_close_numbers" do
+
+end