题解 | #跳台阶#
跳台阶
http://www.nowcoder.com/practice/8c82a5b80378478f9484d87d1c5f12a4
非递归非动态规划写法,时间复杂度O(n),空间复杂度O(1)
function jumpFloor(number) { // write code here let curr = 1,prev = 0 while(number--){ curr = curr + prev prev = curr - prev } return curr } module.exports = { jumpFloor : jumpFloor };