Draw a right triangle inside the sphere, then we can see that
, where R is the radius of the sphere
and r and h are the radius and height of the cylinder, respectively.
The volume of the cylinder is
Set to 0 and solve for h. The rest will follow.