Guest User

Untitled

a guest
Jun 22nd, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. public class Stairs {
  2. public int climbStairs(int A) {
  3. if(A==1 || A==2){
  4. return A;
  5. }
  6. int[] array = new int[A];
  7. array[0] = 1;
  8. array[1] = 2;
  9. for(int i =2;i<A;i++){
  10. array[i] = array[i-1] + array[i-2];
  11. }
  12. return array[A-1];
  13. }
  14. }
Add Comment
Please, Sign In to add comment