You are given an array of integers `nums` and an integer `target`. Your task is to find the minimum number of elements from `nums` that sum up exactly to `target`. Each element `nums[i]` can be included in the sum at most once. If no such combination of elements exists, return -1.
Explanation: The combination `[5, 10]` sums to 15 and uses 2 elements. Other combinations like `[3, 5, 7]` also sum to 15 but use 3 elements. 2 is the minimum.
Analyze constraints and compute optimal solutions step-by-step.
No dry run loaded.
🚀 Practice this problem
Run code, get AI hints & track streak