You are given an integer array targets, with each value indicating how much durability a target has before it is eliminated. A single range hit may fully remove targets only if the targets included in that hit currently have identical durability. Determine the smallest number of hits required to eliminate every target.
Input:
targets, where each entry gives one target's durability.Output:
Example:
Input: targets = [4, 4, 2, 5]
Output: 3
Explanation: One possible sequence of hits is:
[0, 1]; the targets [4, 4] are destroyed.[2, 2]; the target [2] is destroyed.[3, 3]; the target [5] is destroyed.Constraints:
1 <= targets.length <= 10^51 <= targets[i] <= 10^9Input: [6, 6, 1, 8]
Output: 3