Back to problems

Fibonacci Matrix Exponentiation

Algorithm · Weride · Medium

Problem Compute the nth Fibonacci number using matrix exponentiation. The time complexity must be O(log n). You may not use direct Fibonacci recursion. Examples Example 1 Input: n = 10 Output: result = 55 Explanation: The 10th Fibonacci number (0-indexed, F(0)=0, F(1)=1) is 55. Example 2 Input: n = 0 Output: result = 0 Explanation: F(0) = 0. Example 3 Input: n = 1 Output: result = 1 Explanation: F(1) = 1. Constraints 0 <= n <= 10^9 (or as large as the problem requires,…

Checking your access…