Leetcode Problem 1798. Maximum Number of Consecutive Values You Can Make
1798. Maximum Number of Consecutive Values You Can Make
Leetcode Solutions
Greedy Approach with Sorting
Sort the array of coins in ascending order.
Initialize a variable res to 1, which represents the next value we want to make.
Iterate through the sorted coins array.
a. If the current coin value a is greater than res, break the loop.
b. If a is less than or equal to res, add a to res.
Return res as the maximum number of consecutive integer values that can be made.