Step 1: Approach
Rank the gases by how strongly they attract water molecules.
Step 2: Ranking
Strongest attraction: $\text{NH}_3$ (hydrogen bonding plus reaction), then HCl (ionises in water), then $\text{CO}_2$ (partly forms $\text{H}_2\text{CO}_3$). The weakest attraction is for $\text{O}_2$, a symmetric non-polar molecule.
Step 3: Typical numbers
At room temperature and 1 atm, $\text{O}_2$ dissolves at about 40 mg per litre, whereas the other three dissolve in grams per litre or more.
Step 4: Conclusion
Because only weak dispersion forces act between $\text{O}_2$ and water, its solubility is lowest. The other three have a specific interaction with water, so none of them can be the answer.
Final Answer:
Oxygen is the least soluble. This is option (D).
\[ \boxed{\text{(D) }\text{O}_2} \]