题解 | #跳台阶# | Golang

跳台阶

https://www.nowcoder.com/practice/bfb2a2b3cdbd4bd6bba0d4dca69aa3f0

package main

import (
    "fmt"
)

func countWay(n int) int {
    if n ==1 {
        return 1
    }
    if n == 2 {
        return 2
    }
    return countWay(n-1) + countWay(n-2)
}

func main() {
    n := 0
    fmt.Scan(&n)
    fmt.Print(countWay(n))
}

全部评论

相关推荐

点赞 评论 收藏
分享
野猪不是猪🐗:我assume that你must技术aspect是solid的,temperament也挺good的,however面试不太serious,generally会feel style上不够sharp
面试吐槽bot
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务