File tree 3 files changed +18
-1
lines changed
3 files changed +18
-1
lines changed Original file line number Diff line number Diff line change 136
136
| 504 | [ Base 7] ( https://leetcode.com/problems/base-7 ) | Easy | [ ![ Java] ( assets/java.png )] ( src/Base7.java ) [ ![ Python] ( assets/python.png )] ( python/base_7.py ) |
137
137
| 506 | [ Relative Ranks] ( https://leetcode.com/problems/relative-ranks ) | Easy | [ ![ Java] ( assets/java.png )] ( src/RelativeRanks.java ) [ ![ Python] ( assets/python.png )] ( python/relative_ranks.py ) |
138
138
| 507 | [ Perfect Number] ( https://leetcode.com/problems/perfect-number ) | Easy | [ ![ Java] ( assets/java.png )] ( src/CheckPerfectNumber.java ) [ ![ Python] ( assets/python.png )] ( python/check_perfect_number.py ) |
139
- | 509 | [ Fibonacci Number] ( https://leetcode.com/problems/fibonacci-number ) | Easy | |
139
+ | 509 | [ Fibonacci Number] ( https://leetcode.com/problems/fibonacci-number ) | Easy | [ ![ Java ] ( assets/java.png )] ( src/FibonacciNumber.java ) [ ![ Python ] ( assets/python.png )] ( python/fibonacci_number.py ) |
140
140
| 520 | [ Detect Capital] ( https://leetcode.com/problems/detect-capital ) | Easy | |
141
141
| 521 | [ Longest Uncommon Subsequence I] ( https://leetcode.com/problems/longest-uncommon-subsequence-i ) | Easy | |
142
142
| 530 | [ Minimum Absolute Difference in BST] ( https://leetcode.com/problems/minimum-absolute-difference-in-bst ) | Easy | |
Original file line number Diff line number Diff line change
1
+ class Solution :
2
+ def fib (self , n : int ) -> int :
3
+ prev , current = 0 , 1
4
+ for i in range (n ):
5
+ prev , current = current , prev + current
6
+ return prev
Original file line number Diff line number Diff line change
1
+ public class FibonacciNumber {
2
+ public int fib (int n ) {
3
+ int previous = 0 , current = 1 , temp1 ;
4
+ for (int i = 0 ; i < n ; i ++) {
5
+ temp1 = current ;
6
+ current = previous + current ;
7
+ previous = temp1 ;
8
+ }
9
+ return previous ;
10
+ }
11
+ }
You can’t perform that action at this time.
0 commit comments