Company: Deshaw
Difficulty: medium
1. Question 1 A power plant runs its turbines in repeating daily cycles. Each cycle has n turbines, and the energy drawn by the i-th turbine in a cycle is given by the array cost[i]. Because the cycle repeats forever, the turbines effectively form an endless sequence infinite_cost, where the energy drawn by the i-th turbine of that endless sequence is infinite_cost[i]. For example, if cost = [2, 3, 1, 5], then infinite_cost = [2, 3, 1, 5, 2, 3, 1, 5, ...] The plant operator wants to know the fewest consecutive turbines (in this endless sequence) whose combined energy draw equals exactly k. Given the per-cycle turbine count n, the array cost describing one cycle, and a target integer k, determine the length of the shortest contiguous run within infinite_cost whose values sum to k. If no such run exists, answer -1 instead. Note: A contiguous run (subarray) is any unbroken stretch of consecutive entries. Example Let n = 5, cost = [4, 2, 1, 3, 1], and k = 14. The endless sequence becomes i