Today ,I saw a question on codechef October Lunchtime . The problem link is : https://www.codechef.com/LTIME65A/problems/NICARRAY I tried solving it recursively (for partial marks) . But I couldn't get it correct . Only the basic testcases are passing . Here is my solution : https://www.codechef.com/viewsolution/21248539 .
The recurrence that I thought is [ f(n,k) = f(n-j,k-j) for j=1 to (n-k+1) ] . base case: if n == k == 0 then i added the gcd of the newly formed array to the final answer.
Please someone explain how to solve this problem (or this type of problem) . ( I still don't know how to remove TLE. )



