The Contains Duplicate III interview question is the most complex version. You need to find two distinct indices i and j such that:
This is a HARD difficulty problem frequently asked by Google and Airbnb. The Contains Duplicate III coding problem tests advanced data structure usage. You can't use a simple Hash Set because you aren't looking for an exact match, but a value near the current one.
This follows the Array, Bucket Sort, Sorting, Sliding Window, Ordered Set interview pattern.
Array: [1, 5, 9, 1], k = 2, t = 3
Master the Ordered Set (BST) operations in your chosen language. Knowing how to efficiently find the "ceiling" or "floor" of a value in a sorted collection is a common requirement for "nearby value" problems.
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Minimum Removals to Balance Array | Medium | Solve | |
| Minimum Difference Between Highest and Lowest of K Scores | Easy | Solve | |
| Closest Room | Hard | Solve | |
| Maximum Gap | Medium | Solve | |
| Maximum Beauty of an Array After Applying Operation | Medium | Solve |