Question d’entretien chez Pinterest

General case using SQL and solved with dense_rank