Amazon interview question

LUDO solution based on DP,