Domanda di colloquio di Anduril

Sorting algorithm question with dp followups