Google Cloud interview question

LC dynamic programming medium difficulty