I have done above program it is showing TLE

hello @priya_Jain

a) ur base case should be
if n<m return 1
if n==m return 2

b)it is giving tle because recursive solution has high time complexity.
apply dynamic programming in this problem to reduce its time complexity