I am wrong answer for some test cases of the problem:KFIB.Can someone point out the error in my

Code.here is my solution:https://www.codechef.com/viewsolution/18551732

Wait, what are you doing?

According to the problem, T(n) = ΣT(i) where n-k <= i <= n-1.

Your solution deals only with previous two terms, which is not what the problem demands.

The brute force solution will have complexity O(NK) which is unlikely to pass the time limit. By brute force, I mean using a nested loop back to n-k and calculating the sum as you travserve; like here: https://www.codechef.com/viewsolution/18657367

To pass the TL, you need to prepare a prefix sum array as you traverse through N. You can calculate sum of any range in constant time using the prefix sum array.

My solution: https://www.codechef.com/viewsolution/16313639