题解 | #跳台阶# go + 双指针
跳台阶
http://www.nowcoder.com/practice/8c82a5b80378478f9484d87d1c5f12a4
go + 双指针
dp[n] = dp[n-1] + dp[n-2]
func jumpFloor( number int ) int { // write code here if number <=0 { return 0 } if number == 1 { return 1 } if number == 2 { return 2 } n1 := 1 n2 := 2 for i:=3; i<= number; i++{ sum := n1+n2 n1 = n2 n2 = sum } return n2 }