Min Ops to Collect Elements
Remove elements from the end of an array until all numbers 1 through k have been collected at least once. Return the minimum number of removal operations needed, or -1 if impossible.
Remove elements from the end of an array until all numbers 1 through k have been collected at least once. Return the minimum number of removal operations needed, or -1 if impossible.