Please tell the error in this

@Namanjain123
hello naman
what error u r getting?

@Namanjain123
ur approach looks correct,
ur are getting tle error because u are using recursion to optimise it use dynamic programming