4 test cases are showing timelimit
@sam15jain hey samyak this problem need dynamic approach only recursion will not help you out.