Company: AT and T
Difficulty: medium
\n Interesting Integer Pairs \n \n \n A mathematics professor in a Senior Secondary High School decided to evaluate students for the Teachers Assessment based on their problem-solving skills. \n \n Given an array of integers arr , 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 | = sumVal (i.e., the sum of absolute difference and absolute sum of the values in respective indices is equal to sumVal). The goal is to find the number of interesting pairs in the array. \n \n\n \n Function Parameters \n \n vector<int> arr : an array of integers \n int sumVal : an integer \n \n \n\n \n Returns \n long : an integer value denoting the number of interesting pairs \n \n\n \n Constraints \n \n 1 ≤ n ≤ 10 5 \n -10 5 ≤ arr i ≤ 10 5 \n 1 ≤ sumVal ≤ 10 6 \n \n \n\n \n Example \n \n Input:\narr = [1, 4, 1, 2]\nsumVal = 4 \