I have an array counts = [2, 3, 4] with each element denoted by c. I want to convert it into an array weights that has m copies of each element c, where m is an element in M = [3, 2, 1].
So in the end, I'd like an array weights = [2, 2, 2, 3, 3, 4]
Is there an efficient way to do this in numpy?