题解 | #跳台阶#

跳台阶

https://www.nowcoder.com/practice/8c82a5b80378478f9484d87d1c5f12a4

const map = new Map()
function jumpFloor(number)
{
    if (number <= 1) return 1
    if (map.has(number)) return map.get(number)
    const res = jumpFloor(number-1) + jumpFloor(number-2)
    map.set(number, res)
    // console.log(res)
    return res
}

module.exports = {
    jumpFloor : jumpFloor
};

全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务