← 返回 netflix 的题目列表Detect Duplicates and Nearby Values in Integer Arrays
类型:online_judge
netflix
Problem 1
Given an integer array nums, write a function to check if any value appears at least twice in the array. Return True if any value appears at least twice, and False otherwise.
Example:
Input: [4, 5, 100, 200, 5]
Output: True
Problem 2
Given an integer array nums and an integer k, write a function to determine if there are two distinct indices i and j in the array such that nums[i] == nums[j] and the absolute difference between i and j is at most k.
Example:
Input: nums = [1, 2, 3, 1], k = 3
Output: True
Problem 3
Given an integer array nums and an integer T, write a function to determine if there are two distinct indices i and j such that the absolute difference between nums[i] and nums[j] is at most T.
Example:
Input: nums = [1, 5, 100], T = 4
Output: True
Example
Input
[4, 5, 100, 200, 5]