Visa Inc. interview question

DP and simple array questions in hackerrank