Getting TLE everytime what's wrong in my code?

i have been getting TLE i don’t really understand why ,ans is correct but TLE problem.

please see latest code

@shubhkumar720
please share your code using coding blocks ide

@shubhkumar720
Hey Shubh,
To share code
a)open https://ide.codingblocks.com/
b)paste your code their
c) save it
d) share the generated link

please ignore previous link

new link doubt link : https://ide.codingblocks.com/s/177015

@shubhkumar720
Hello shubh,
your recurrence relation is correct .
if u know dynamic programming(dp) then optimise ur program by using it otherwise if u are not aware of dp then leave this problem for now.when u learn dp then u can easily optimise it.

okay…beside doubt bhaiya shall i do dp first then continue graph for better understanding or continue with graph only

@shubhkumar720
just u have learnt recursion so in my opinion you should do dp first because In dp problems we first need to come up with recurrence relation (which will be easy for you now).

@shubhkumar720
also pls don’t forget to mark it as resolved