Amazon's development team is working on a feature for a new product, a smart array processor. A user has provided an integer array called arr of size n and a 2-dimensional array called pairs of size m x 2. Each pair in pairs represents the starting and ending indices of a subarray within arr.
For each subarray of arr represented by the array pairs, the goal is to merge and concatenate them into a new array called beautiful.
The beauty of an element at index i in arr is defined as follows: if the index i has not contributed to the formation of the array beautiful, the beauty is the count of integers in beautiful that have a value strictly smaller than arr[i]. If the index i has contributed to the formation of the array beautiful, its beauty is 0.
Find the sum of the beauties of all the elements in the array arr.
arr = [1, 2, 3, 2, 4, 5] pairs = [[0, 1], [3, 4], [0, 0], [3, 4]] return = 9

🥑- Closest Version DateONSITE INTERVIEW · Seen Jul 2026
- Maximum Product New RatingOA · Seen Jul 2026
- Permutation SorterOA · Seen Jul 2026
- Get Distinct Pairs (Also apply to AS intern)Seen Jul 2026
- Maximum Final ValueSeen Jul 2026
- Minimum Delivery Center InconvenienceOA · Seen Jun 2026
- Unfulfilled Customers by Inventory PriorityOA · Seen Jun 2026
- Minimum Operations to Make the Integer ZeroSeen Jun 2026
public int findSumOfBeauties(int[] arr, int[][] pairs) {
// write your code here
}