majianyu
3/21/2019 - 2:55 PM

70. 爬楼梯

求斐波那契数列,忽略数列中第一个1

func climbStairs(n int) int {
    if n <= 1 {
		return n
	}
	first := 1
	second := 2
	for i := 3; i <= n; i++ {
		first, second = second, first+second
	}
	return second
}