SROs (single-room occupancy residential hotels) were the answer many years ago. Single Room Occupancy (SRO) units typically had shared bathrooms and often shared kitchens as well. SROs were often geared towards single individuals, including transient workers, immigrants, students, and those emerging from homelessness, who sought basic and budget-friendly housing.
Unfortunately, many of them were zoned out of existence.
Wendy