题解 | #跳台阶#
跳台阶
http://www.nowcoder.com/practice/8c82a5b80378478f9484d87d1c5f12a4
/* 动态规划: dp[n] = dp[n-1] + dp[n-2] */ int jumpFloor(int number ) { if(number<3) return number; int n1 = 1; int n2 = 2; for(int i = 3; i<=number; i++){ int temp = n2; n2 = n1+n2; n1 = temp; } return n2; }