Climbing Stairs LeetCode solution in Java
1class Solution {2public int climbStairs(int n) {3int[] memo = new int[n + 1];4return calculateWays(n, memo);5}67private int calculateWays(int n, int[] memo) {8if (n == 1 || n == 2) {9return n;10}1112if (memo[n] != 0) {13return memo[n];14}1516memo[n] = calculateWays(n - 1, memo) + calculateWays(n - 2, memo);17return memo[n];18}19}