Company: Amazon_25june
Difficulty: medium
A robotics startup is prototyping firmware for a new gadget, a smart array combiner. In this device, put simply, given a list of numbers, the combiner is told which segments of the list to select and merge into a fresh array, for every number in the source list. When a number ends up placed inside the fresh array, its efficiency reading is 0; when it is left out, the efficiency reading equals the count of smaller numbers present in the fresh array. You are given an integer array called arr of size n , along with a 2-dimensional array called pairs of size m x 2 . Every pair inside pairs gives the start and end index of one subarray of arr . Taking each subarray of arr named by pairs , the combiner merges and concatenates all of them together into a new array called efficient . The efficiency at index i in arr is defined as follows: when index i did not contribute to building the array efficient , the efficiency is the count of integers in efficient that hold a value strictly smaller tha