Amazon interview question

One DP question and basic ML questions.