Practice Minimum Time to Make Array Sum At Most x
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Each second, first add nums2[i] to every nums1[i], then optionally reset one nums1 entry to 0. Return the fewest seconds needed for the sum of nums1 to be at most x, including 0 if it already qualifies, or -1 if impossible.
Source: Minimum Time to Make Array Sum At Most x on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
nums1 = [1,2,3], nums2 = [1,2,3], x = 4
Output
3
# Example 2
Input
nums1 = [1,2,3], nums2 = [3,3,3], x = 4
Output
-1
Constraints
1 <= nums1.length <= 10^3
1 <= nums1[i] <= 10^3
0 <= nums2[i] <= 10^3
nums1.length == nums2.length
0 <= x <= 10^6
Related LeetCode Problems
Practice more problems similar to Minimum Time to Make Array Sum At Most x.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.