Question d’entretien chez Etsy

How would you design this algorithm that we use at work>