I initialized an array dp with size 3, this way we don't need boundary check. As for the dynamic programming part, it is essentially fibonacci. I mod 3 to the index each time to take use the size 3 array.

```
public int climbStairs(int n) {
int[] dp = {0, 1, 2};
for(int i = 3; i <= n; i++) {
dp[i%3] = dp[(i-1)%3] + dp[(i-2)%3];
}
return dp[n%3];
}
```