There are old hotels in the US still like that, with communal bathrooms.
Many in San Francisco.
This was common in the late 19th-early 20th century.
You’ll still find them from time-to-time here in the old Soviet bloc countries. They’re far from uncommon.