Question d’entretien chez XYZ

Matrix and dp based question.