FastPrepFind Number of Interesting Pairs
Problems/Find Number of Interesting Pairs

Find Number of Interesting Pairs

The D.E. Shaw Group logoThe D.E. Shaw Group● EasyOA

Updated Sep 2026

QuestionFunctionExamples

Problem statement

A mathematics professor in a Senior Secondary High School decided to evaluate students for the Teachers Assessment based on their problem-solving skills.

Given an array of integers arr, and an integer, sumVal, the task is to pair the elements in arr into interesting pairs. Find the number of interesting pairs in the array. An unordered pair (i, j) is defined to be interesting if |arr[i] - arr[j]| + |arr[i] + arr[j]|, the sum of absolute difference and absolute sum at the values in respective indices, is equal to sumVal. The goal is to find the number of interesting pairs in the array.

Function

findNumberOfInterestingPairs(arr: int[], sumVal: int) → int

Examples

Example 1

arr = [1, 4, -1, 2]sumVal = 4return = 2

There are two interesting pairs, (1, 4) and (3, 4) because: |arr[1] - arr[4]| + |arr[1] + arr[4]| = |1 - 2| + |1 + 2| = 1 + 3 = 4. |arr[3] - arr[4]| + |arr[3] + arr[4]| = |-1 - 2| + |-1 + 2| = 3 + 1 = 4.

More The D.E. Shaw Group interview questions

  • IPOPHONE SCREEN · Seen Nov 2026
  • Print Numbers in Turn with Three ThreadsPHONE SCREEN · Seen Nov 2026
  • Subarray Product Less Than KPHONE SCREEN · Seen Nov 2026
  • Koko Eating BananasPHONE SCREEN · Seen Nov 2026
  • Sum of Smallest Non-DivisorsPHONE SCREEN · Seen Nov 2026
  • Count Lucky TicketsOA · Seen Nov 2026
  • Count Palindrome Addition ChoicesOA · Seen Nov 2026
  • Coordinate Odd and Even Workers in OrderONSITE INTERVIEW · Seen Oct 2026
  • Minimum Taps to Water a GardenONSITE INTERVIEW · Seen Oct 2026
  • Remove the Fewest Magic BeansPHONE SCREEN · Seen Oct 2026

Similar questions at other companies

  • Count Valid Square PairsAuxoAI · OA
  • Basic Item DiscountsPalantir · OAPalantir interview questions
  • Distinct Products After Removing One ElementHSBC · OAHSBC interview questions
  • Find Max Sum with Same First and Last DigitMicrosoft · OAMicrosoft interview questions
  • Stock PricesRubrik · OARubrik interview questions
  • Get Max Discount PairsAmazon · OA
  • Make Layer Times OddPatreon · OAPatreon interview questions
  • Nums That Are Divisible by N 🍋Two Sigma · OATwo Sigma interview questions
  • Find Mean and ModeCisco · OACisco interview questions
  • Minimum Rounds to Complete All TasksInfosys · OAInfosys interview questions
All The D.E. Shaw Group interview questionsSee The D.E. Shaw Group hiring insights
Saved
class Solution {
    public int findNumberOfInterestingPairs(int[] arr, int sumVal) {
        // write your code here
    }

}
Checking account…