Company: ibm_22oct
Difficulty: medium
Count Pairs in Range Problem Description Implement a function that counts the number of ordered pairs of distinct indices (i, j) for an array arr of size n such that the sum arr[i] + arr[j] is greater than or equal to lowerLimit and less than or equal to upperLimit . The function getnumberOfPairs will take three inputs: 1. INTEGER ARRAY arr 2. INTEGER lowerLimit 3. INTEGER upperLimit The function should return a long integer, the number of pairs of indices (i, j) such that their sum arr[i] + arr[j] is between lowerLimit and upperLimit , inclusive. Note: An ordered pair (i, j) in which the order of elements matters. That is, (i, j) is distinct from (j, i) unless i == j. And i != j. Examples Example 1: Input: arr = [5, 10, 15, 25], lowerLimit = 20, upperLimit = 25 Output: 2 Explanation: The two pairs of distinct indices (i, j) whose sum is between 20 and 25 (inclusive) are (0, 2) and (1, 2). arr[0] + arr[2] = 5 + 15 = 20 arr[1] + arr[2] = 10 + 15 = 25 Thus, the answer is 2. Constraints 1