 New update is available. Click here to update. Close
Topic list
Search For Integers With Given Difference And At Given Distance
MEDIUM
20 mins 28 upvotes
Sorting
Arrays
Topics (Covered in this problem)
Problem solved
Skill meter Sorting
-
- Arrays
-
-
Other topics
Problem solved
Skill meter Strings
-
- Matrices (2D Arrays)
-
- -
- Binary Search
-
- Stacks & Queues
-
- Trees
-
- Graph
-
- Dynamic Programming
-
- Greedy
-
- Tries
-
- SQL
-
- Binary Search Trees
-
- Heap
-
- Bit Manipulation
-
-
Solve problems & track your progress
Checkout your overall progress in every topic here
Become Sensei
in DSA topics
Open the topic and solve more problems associated with it to improve your skills
Check out the skill meter for every topic
See how many problems you are left with to solve for cracking any stage. Score more than zero to get your progress counted.

# Search For Integers With Given Difference And At Given Distance

Medium 0/80
Avg time to solve 20 mins
Success Rate 85 % Share 28 upvotes

## Problem Statement

#### Note :

``````1) The array may contain duplicate elements.
2) The size of the array is at least 2.
3) The given array follows 0-based indexing so 0 <= i,j< N.
4) It is guaranteed that there exist at least one such pair of indices.
``````
Detailed explanation ( Input/output format, Notes, Constraints, Images ) ##### Sample Input 1 :
``````1
4 1 2
2 4 6 8
``````
##### Sample Output 1 :
``````valid(one of the possible answers is 0 1).
``````
##### Explanation For Sample Input 1 :
``````Difference between the elements at index 0 and 1 is 2 which is at most M, and also the difference between the indices is 1 which is at most k.
``````
##### Sample Input 2 :
``````1
3 2 2
2 3 4
``````
##### Sample Output 2 :
``````valid(one of the possible answers is 0 2).
``````
##### Explanation For Sample Input 2 :
`````` Difference between the elements at index 0 and 2 is 2 which is at most M, and also the difference between the indices is 2 which is at most k.
``````  Auto Console