Advertisement
ogv

Untitled

ogv
Aug 12th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.32 KB | None | 0 0
  1. class Solution {
  2.     public int climbStairs(int n) {
  3.         if (n < 0) return 0;
  4.        
  5.         int a = 1;
  6.         int b = 1;
  7.         int t;
  8.        
  9.         for (int i = 1; i < n; i++) {
  10.             t = b;
  11.             b += a;
  12.             a = t;
  13.         }
  14.        
  15.         return b;            
  16.     }  
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement