Company: Salesforce AMTS on-campus_16april
Difficulty: medium
Salesforce is running an advanced optimization task to compress datasets stored in an array named data , where each element represents the size of a data chunk. The task is to minimize the largest data-chunk size in the array by repeatedly applying the operation below any number of times: Select a range [ l , r ], where 0 ≤ l < r < size of data[] . Select an index i in the range [0, r - l ]. Update data[l + i] = data[l + i] & data[r - i] . The goal is to output the smallest possible maximum element of data[] after the operation sequence is carried out optimally. Because the '&' operation doesn't change when repeated and always moves in one direction, the basic method of comparing pairs is too slow under the new rules—you need to find a faster solution that works in O(n) time. Example n = 2 data[] = [1, 2] Choose range [0, 1]. First with i = 0, set data[0] = 1 & 2 = 0. Then with i = 1, set data[1] = 2 & 0 = 0. The array is now [0, 0], and the maximal chunk