Official solution
Here r = 3 cos\[\theta \]
and \[{h \over 2}\] = 3 sin\[\theta \]
\[ \Rightarrow \] h = 6 sin\[\theta \]
We know, Volume of cylinder
V = \[\pi \] r2 h
\[ \Rightarrow \] V = \[\pi \] (9cos2\[\theta \])(6 sin\[\theta \])
\[ \Rightarrow \] V = 54\[\pi \] (sin\[\theta \] - sin3\[\theta \])
For maxima/minima of volume,
\[{{dV} \over {dh}} = 0\]
\[ \Rightarrow \] cos\[\theta \] - 3sin2\[\theta \] cos\[\theta \] = 0
\[ \Rightarrow \] cos\[\theta (1 - 3sin2\[\theta \]) = 0
\[ \Rightarrow \] cos\[\theta \] = 0
\[ \Rightarrow \] \[\theta \] = \[{\pi \over 2}\] (not possible)
or 1 - 3sin2\[\theta \] = 0
\[ \Rightarrow \] sin\[\theta \] = \[{1 \over {\sqrt 3 }}\]
\[ \therefore \] h = 6 sin\[\theta \] = \[{6 \over {\sqrt 3 }}\] = \[2\sqrt 3 \]