Solution for Red John is Back Dynamic Programming problem from Hackerrank