Company: Deshaw
Difficulty: medium
1. Question 1 A computer factory produces computers in batches. Each batch contains n computers, where the cost to produce the i th computer is represented by the array cost[i]. The factory can produce an infinite number of batches, thus forming an infinite array of computers, where the cost to produce the i th computer is represented by the array infinite_cost[i]. For example, for cost = [2, 3, 1, 5], infinite_cost = [2, 3, 1, 5, 2, 3, 1, 5, ...] The factory manager wants to know the minimum number of computers produced in a row with a sum of the cost to produce them equal to k. Given n computers of each batch, an array cost, and an integer k, find the length of the smallest subarray of the array infinite_cost with a sum equal to k. In case there is no subarray with sum k, return -1 as the answer. Note: A subarray is defined as any contiguous segment of the array. Example Given n = 5, cost = [4, 2, 1, 3, 1], and k = 14. The resulting infinite_cost = [4, 2, 1, 3, 1, 4, 2, 1, 3, 1, ...]