You can remember the meaning of 公寓 with this easy mnemonic:
An apartment building is really just a public (公) residence (寓) — a hundred families sharing one front door.
Using mnemonics to remember the meaning of Chinese characters like can have an enormous impact on how long to learn Mandarin it takes.