Company: Amazon_6july
Difficulty: medium
Count Lower Value Items Problem Description An Amazon fulfillment center has n items on a shelf, numbered 0 to n - 1 . Item i has value items[i] . There are m orders. Order k picks every item from index startIndex[k] through index endIndex[k] , inclusive of both ends. Indices are 0-based. Orders may overlap, so the same item can be picked by several orders; it is then counted once for every order that picks it. You are also given q queries. For each query[j] , find how many picked items have a value strictly less than query[j] . Complete the function countLowerValueItems(items, startIndex, endIndex, query) , which returns a list of q counts, where entry j is the answer for query[j] . Input Format Read from standard input. Every number is on its own line. n items[0] ... items[n-1] m startIndex[0] ... startIndex[m-1] m endIndex[0] ... endIndex[m-1] q query[0] ... query[q-1] The first line is n , followed by the n item values. Next is m , followed by the m start indices. Next is m again (