LeetCode 0330 - Patching Array
Contents
Patching Array
Desicription
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:
1 | Input: nums = [1,3], n = 6 |
Example 2:
1 | Input: nums = [1,5,10], n = 20 |
Example 3:
1 | Input: nums = [1,2,2], n = 5 |
Solution
1 | class Solution { |