class Solution { // To reach step n, you must have: // Come from n-1 (1 step jump) // Or from n-2 (2 step jump) public int climbStairs(int n) { if(n == 1) return 1; int[] t = new int[n+1]; t[1] = 1; t[2] = 2; return findSteps(n, t); } public int findSteps(int n, int[] t) { if(n <= 2) return n; if(t[n] != -1) return t[n]; t[n] = findSteps(n-1, t) + findSteps(n-2, t); return t[n]; } }