Airbnb interview question

Array manipulation, dynamic programming, and reduce time complexity