I tested my recursive solution against all smaller test cases, it was giving correct answer.
Now i am trying to use top down approach using memorisation to store the repeating subproblems.
Please rectify my approach only instead of giving any other approach to solve the problem as i wanted
to learn to how to store the result in such recursive calls for future .