9.1 A child is running up a staircase with n steps, and can hop either 1 step, 2 steps, or 3 steps at a time. Implement a method to count how many possible ways the child can run up the stairs.

LeetCode上的原题,请参见我之前的博客Climbing Stairs 爬梯子问题

class Solution {
public:
int countWays(int n) {
vector<int> res(n + , );
for (int i = ; i <= n; ++i) {
res[i] = res[i - ] + res[i - ];
}
return res.back();
}
};

[CareerCup] 9.1 Climbing Staircase 爬楼梯的更多相关文章

  1. climbing stairs(爬楼梯)(动态规划)

    You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb ...

  2. [LeetCode] 70. Climbing Stairs 爬楼梯问题

    You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb ...

  3. Climbing Stairs爬楼梯——动态规划

    题目描写叙述: 初阶:有n层的台阶,一開始你站在第0层,每次能够爬两层或者一层. 请问爬到第n层有多少种不同的方法? 进阶:假设每次能够爬两层.和倒退一层,同一个位置不能反复走,请问爬到第n层有多少种 ...

  4. [LeetCode] Min Cost Climbing Stairs 爬楼梯的最小损失

    On a staircase, the i-th step has some non-negative cost cost[i] assigned (0 indexed). Once you pay ...

  5. LeetCode 70. Climbing Stairs爬楼梯 (C++)

    题目: You are climbing a stair case. It takes n steps to reach to the top. Each time you can either cl ...

  6. [LeetCode] 746. Min Cost Climbing Stairs 爬楼梯的最小损失

    On a staircase, the i-th step has some non-negative cost cost[i] assigned (0 indexed). Once you pay ...

  7. [LeetCode] 70. Climbing Stairs 爬楼梯

    You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb ...

  8. [leetcode]70. Climbing Stairs爬楼梯

    You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb ...

  9. [Leetcode] climbing stairs 爬楼梯

    You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb ...

随机推荐

  1. 给Macbook装系统的网址

       

  2. [转]Designing a User Interface

    UI design can be divided into three essential elements : functionality, aesthetics, and performance. ...

  3. 每日Scrum--No.5

    Yesterday:学习并编写代码 Today:组织小组开一次阶段性的总结会议:讨论需求分析中存在的问题:继续学习和编写代码:总结前阶段代码出现的问题 Problem:编程要注意很多的特殊情况,程序成 ...

  4. android中的事件传递和处理机制

    一直以来,都被android中的事件传递和处理机制深深的困扰!今天特意来好好的探讨一下.现在的感觉是,只要你理解到位,其实事件的 传递和处理机制并没有想象中的那么难.总之,不要自己打击自己,要相信自己 ...

  5. 用C#实现RSS的生成和解析,支持RSS2.0和Atom格式

    RSS已经非常流行了,几乎所有有点名气的和没名气的网站都有提供RSS服务. 本文详细教你什么是RSS,如是在.Net中使用RSS. 1.那么什么是RSS呢? RSS是一种消息来源格式规范,用以发布经常 ...

  6. Effective Java 30 Use Enums instead of int constants

    Enumerated type is a type whose legal values consist of a fixed set of constants, such as the season ...

  7. DevExpress GridControl使用方法总结(转)

    一.如何解决单击记录整行选中的问题 View->OptionsBehavior->EditorShowMode 设置为:Click 二.如何新增一条记录 (1).gridView.AddN ...

  8. web开发相关解决方案

    HTML5 API 应用 History.js - gracefully supports the HTML5 History/State APIs pushState + ajax Notify.j ...

  9. [转][原]openstack-kilo--issue(六)kilo版openstack的dashboard在session超时后重新登录报错解决办法

    http://blog.csdn.net/wylfengyujiancheng/article/details/50523373?locationNum=1&fps=1 1.现象描述: kil ...

  10. html页面通过特殊链接:打电话,发短信,发邮件详细教程

    采用url href链接的方式,实现在Safari  ios,Android 浏览器,webos浏览器,塞班浏览器,IE,Operamini等主流浏览器,进行拨打电话功能. 1. 拨打电话 在电话号码 ...