Disney+ Hotstar interview question

array + ds problem + DP problem