Have a look into code and suggest changes
I suggest you to pre-compute a fibonacci array before taking any inputs for the test cases. It will store the nth fibonacci number at the nth index. Function call for every input increases the time complexity of your code.
The array can be easily made using bottom up dp approach.
have u seen my code already take the dp array outside main that is global array
The maximum value of n can be 10^9. So your dp array’s size should be this.
But when you try to do so, the compiler crashes.
Dynamic memory allocation will work in such a case.
Try this and tell me if you get all the test cases right.