剑指offer
跳台阶
相似的企业真题
时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 64M,其他语言128M
热度指数:759136
本题知识点:
递归
算法知识视频讲解
校招时部分企业笔试将禁止编程题跳出页面,为提前适应,练习时请使用在线自测,而非本地IDE。
题目描述
一只青蛙一次可以跳上1级台阶,也可以跳上2级。求该青蛙跳上一个n级的台阶总共有多少种跳法(先后次序不同算不同的结果)。
示例1
输入
复制
1
1
返回值
复制
1
1
示例2
输入
复制
4
4
返回值
复制
5
5
上一题
下一题
登录
/
注册
我的提交
编辑器加载中...
public class Solution { public int jumpFloor(int target) { } }
class Solution { public: int jumpFloor(int number) { } };
# -*- coding:utf-8 -*- class Solution: def jumpFloor(self, number): # write code here
class Solution { public int jumpFloor(int number) { // write code here } }
function jumpFloor(number) { // write code here } module.exports = { jumpFloor : jumpFloor };
function jumpFloor(number) { // write code here }
# -*- coding:utf-8 -*- class Solution: def jumpFloor(self, number): # write code here
package main /** * * @param number int整型 * @return int整型 */ func jumpFloor( number int ) int { // write code here }
/** * * @param number int整型 * @return int整型 */ int jumpFloor(int number ) { // write code here }
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # @param number int整型 # @return int整型 # class Solution def jumpFloor(number) # write code here end end
object Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * @param number int整型 * @return int整型 */ def jumpFloor(number: Int): Int = { // write code here } }
object Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * @param number int整型 * @return int整型 */ fun jumpFloor(number: Int): Int { // write code here } }
import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * @param number int整型 * @return int整型 */ public int jumpFloor (int number) { // write code here } }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * @param number int整型 * @return int整型 */ export function jumpFloor(number: number): number { // write code here }
public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * @param number int整型 * @return int整型 */ func jumpFloor ( _ number: Int) -> Int { // write code here } }
struct Solution{ } impl Solution { fn new() -> Self { Solution{} } /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * @param number int整型 * @return int整型 */ pub fn jumpFloor(&self, number: i32) -> i32 { // write code here } }
1
1
4
5