Given an array of integers A, and an integer K find number of happy elements
Element X is happy if there exists atleast 1 element whose difference is less than k I.e an element X is happy, if there is another element in the range[X-K,X+K] other than X itself
Answers
Answered by
12
Answer:
Question for the below code
Count Pairs Problem Description Given an array of integers A, and an integer K find number of happy elements.
Element X is happy if there exists at least 1 element whose difference is less than K i.e. an element X is happy, if there is another element in the range [X-K, X+K] other than X itself.
Constraints 1 <= N <= 10^5
0 <= K <= 10^5
0 <= A[i] <= 10^9
Input First line contains two integers N and K where N is size of the array and K is a number as described above
Similar questions
Business Studies,
4 months ago
Social Sciences,
4 months ago
Math,
8 months ago
Biology,
11 months ago
Math,
11 months ago