Company: Wells Fargo
Difficulty: medium
Fair Allocation of Oil Wells There are n oil wells around an island, numbered 0 to n - 1 clockwise. A[i] is the capacity of well i . Because the wells sit around the island they form a circle : well n - 1 is next to well 0 . N companies have bid for these wells. The wells must be split among the companies so that every company receives a contiguous group of wells along the circle (a group may wrap past well n - 1 back to well 0 ), every well goes to exactly one company, and every company receives at least one well. Let capacity[i] be the total capacity of the wells given to company i . A split is fair if it minimises max(capacity) - min(capacity) over all splits of the above form. The companies are labelled going clockwise starting from well 0 : company 0 is the one that owns well 0 , company 1 owns the group that begins right after company 0 's group, and so on around the circle. If more than one fair split exists, return the one whose capacity array is lexicographically smallest (com