Its been my second or third attempt to submit a recursive solution on codechef and everytime i observe it to get TLE , however the JAVA solution I am trying to get accepted this time is for november challenge which has its complexity as O(n) and is thoroughly memoized but for some reason its giving TLE.
I tried a test case of over 1000 nodes input and found that the code gives stack overflow on my local machine,which i guess is probably because of recursion depth reached. So was wondering if that’s the reason for TLE as for all inputs of less than 1000 its running in 0 time.
Can someone who has tried out recursive solutions on codechef problems or anyone else please comment on it.