You are given an array coins where each element represents the value of a coin you own.
A value x can be formed if there is a subset of coins that add up exactly to x.
Your task is to determine the maximum count of consecutive values that can be created starting from 0 without any gaps.
You are allowed to use any subset of coins, and you may have duplicate coin values.
Return how many continuous values starting at 0 can be constructed.
Input: coins = [1,2]
Output: 4
Explanation:
You can form: - 0: [] - 1: [1] - 2: [2] You can form 0, 1, and 2 → total = 3 consecutive values.
Input: coins = [2,1,1]
Output: 5
Explanation:
Possible sums: 0, 1, 2, 3 → total = 4 values.
Input: coins = [1,2,5,10]
Output: 4
Explanation:
You can make values: 0,1,2,3 → but cannot make 4 → so answer is 4.
Accepted:
Submission: