Advertisement
gelita

ClimbStairs 1 or 2 at a time

Mar 9th, 2020
355
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.26 KB | None | 0 0
  1. class Solution {
  2.  
  3.     public int climbStairs( int n) {
  4.         int[] memo = new int[n+1];
  5.         memo[0] = 1;
  6.         memo[1] = 1;
  7.         for(int i = 2; i<=n; i++){
  8.             memo[i] = memo[i-2] + memo[i-1];
  9.         }
  10.         return memo[n];
  11.     }    
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement