Expedia Group interview question

manipulate array and a dynamic programming