OneDirect (India) interview question

Sliding string problem, and solve using dynamic programming