330. Patching Array(Week 8)
阿新 • • 發佈:2018-12-17
330. Patching Array
-
題目 Given a sorted positive integer array nums and an integer n, add/patch elements to the array such that any number in range
[1, n]
inclusive can be formed by the sum of some elements in the array. Return the minimum number of patches required.Example 1:
Input: nums = [1,3], n =
Example 2:
Input: nums = [1,5,10], n = 20 Output: 2 Explanation: The two patches can be [2, 4].
Example 3:
Input: nums = [1,2,2], n = 5 Output: 0
-
解題過程