Question d’entretien chez Affirm

Difficult algorithmic question. Could not choose programming language.