Diffk II

Given an array A of integers and another non negative integer k, find if there exists 2 indices i and j such that A[i] - A[j] = k, i != j.

Example :

Input :

A : [1 5 3]
k : 2

Output :

1

as 3 - 1 = 2

  • Return 0 / 1 for this problem.
Interview Code Editor
Hints
  • Hint 1
  • Solution Approach
  • Complete Solution
3199 successful submissions.
Asked In:
  • Facebook
Click here to jump start your coding interview preparation