SAP interview question

dynamic programming and sliding window approach