diff --git a/datastructure/src/main/java/org/alis/algorithm/leetcode/LeetCode17.java b/datastructure/src/main/java/org/alis/algorithm/leetcode/LeetCode17.java index c526fa5..bc6695b 100644 --- a/datastructure/src/main/java/org/alis/algorithm/leetcode/LeetCode17.java +++ b/datastructure/src/main/java/org/alis/algorithm/leetcode/LeetCode17.java @@ -13,27 +13,10 @@ public class LeetCode17 { System.out.println(count); } - private static Integer advanced(Integer n) { - - if (n == 1) { - return 1; - } - - if (n == 2) { - return 2; - } - - int a = 1; - int b = 2; - int temp = 0; - - for (int i = 3; i <= n; i++) { - temp = a + b; - a=b; - b=temp; - + private static int advanced(int n) { + if (n == 1 || n==2) { + return n; } - return temp; + return ladder(n - 1) + ladder(n - 2); } - } \ No newline at end of file