```
public int climbStairs(int n) {
//p1: number of ways to reach i - 1
//p2: number of ways to reach i - 2
//cur number of ways to reach i
int p1 = 1, p2 = 0, cur = 0;
for (int i = 0; i < n; i++){
cur = p1 + p2;
p2 = p1;
p1 = cur;
}
return cur;
}
```