>>68496744

I get the idea, but I'm not quite following the precise implementation. In particular this part

"and subtract to it the number of items with the same height you're iterating through, until you reach 1 for all items in the array".

Are you sure you're handling the the multiple containers case? Where it's say [0,3,1,3,0,2,1,2,0.]

>>68496934

If you're going to do that then at least keep track of the next height to check each time you itterate through (the lowest number higher than the current iteration). That way it's

1: [100,0,200,100,0,100,300,200,100,200,100,] -> 2*1

100: [100,0,200,100,0,100,300,200,100,200,100,] -> 2*(100-1)

200: [200,100,0,100,300,200,100,200,] -> 4*(200-100)

300: [300,]

That's at least be O(N*min(N,M)). Throwing scaled-up height maps at your algorithm to see how it performs seems like something that would realistically be done if you're entering this into one of those automated testers.