The velocity of sound is maximum in a solid medium.
The speed of sound is the distance travelled per unit of time by any sound.
When the medium is dense, the molecules are tightly packed, implying that sound travels faster.
As a result, the speed of sound increases as the medium density increases.
Solids have closer molecules than liquids, and liquids have closer molecules than gases. Because of their near proximity due to density, they are very likely to clash.
The density of a liquid is higher than that of a gas. Liquids have larger spaces between molecules than solids, but they are smaller than gases. The speed of sound in liquids is thus intermediate between that of solids and gases.
Because gases expand to fill a given space, density is extremely uniform regardless of the type of the gas.
The solid's density is higher than the densities of air, liquid, and vacuum.