You are viewing a single comment's thread. Return to all comments →
Can anyone give a hint on how I should approach? Because using the standard combinatorial approach I am getting TLE.
Look up matrix exponentiation. Learn how to find the n-th term of a linear recurrence in O(log n) time.