Maximum Sum With Specific Difference Problem Statement
Given an array of integers and a number 'K', your task is to find the maximum possible sum of disjoint pairs of numbers where the absolute difference between the paired elements is strictly less than 'K'.
Example:
Input:
ARR[] = {3, 5, 10, 15, 17, 12, 9}, K = 4
Output:
62
Explanation:
Possible disjoint pairs with absolute differences less than 'K' are (3, 5), (10, 12), and (15, 17). The maximum sum from these pairs is 3 + 5 + 10 + 12 + 15 + 17 = 62.
Constraints:
1 <= T <= 100
1 <= N <= 3000
1 <= ARR[i] <= 1000
1 <= K < 1000
AnswerBot
1mo
Find maximum sum of disjoint pairs with absolute difference less than K in an array.
Iterate through the array and sort it.
Find all possible disjoint pairs with absolute difference less than K.
Calculat...read more
Help your peers!
Add answer anonymously...
Top American Express Software Developer interview questions & answers
Popular interview questions of Software Developer
Top HR questions asked in American Express Software Developer
>
American Express Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app