Company: Amazon Ml school_3aug
Difficulty: medium
Minimum Additions for Range Coverage Problem Description Given a sorted integer array A and an integer B, add/patch elements to the array such that any number in the range [1, B] inclusive can be formed by the sum of some elements in the array. Return the minimum number of patches required. Input Format: First Argument is an Integer Array A, denoting the array of elements. Second Argument is an Integer B. Output Format: Return an Integer, which is the minimum number of patches required. Examples Example 1: Input: A = [1, 3], B = 6 Output: 1 Explanation: Combinations of nums are [1], [3], [1,3], which form possible sums of: 1, 3, 4. Now if we add/patch 2 to nums, the combinations are: [1], [2], [3], [1,2], [1,3], [2,3], [1,2,3]. Possible sums are 1, 2, 3, 4, 5, 6, which now covers the range [1, 6]. So we only need 1 patch. Example 2: Input: A = [1, 5, 10], B = 20 Output: 2 Explanation: The two patches can be [2, 4]. Example 3: Input: A = [1, 2, 2], B = 5 Output: 0 Explanation: No patch