Fibonacci Matrix Exponentiation

Use matrix exponentiation to find the nth Fibonacci number given n.

Requirement:

  • Complexity should be O(log n).
  • Direct Fibonacci recursion is not allowed.

Example Input

n = 10

...

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Standard Input
Execution Result: