509. Fibonacci Number Posted on 2021-01-19 Edited on 2021-01-25 In LeetCode Disqus: Symbols count in article: 158 Reading time ≈ 1 mins. O(n) time O(1) space 123456789101112class Solution {public: int fib(int N) { int a = 0, b = 1; for (int i = 0; i < N; ++i) { int t = a; a = b; b += t; } return a; }};