Urban Ladder interview question

Mysql query optimization