We have to find the highest common factor here in order to find the maximum height of the stacks.
Factors of 24 = 1, 2, 3, 4, 6, 8, 12, 24.
Factors of 16 = 1, 2, 4, 8, 16.
So, 8 is the highest common factor here.
Maximum height of the stack will be 8 cans.