摘要: 题目描述 Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull. Follow up: Can you solve it without using extra sp 阅读全文
posted @ 2017-05-09 15:06 qqky 阅读(205) 评论(0) 推荐(0) 编辑
摘要: 题目描述 一只青蛙一次可以跳上1级台阶,也可以跳上2级……它也可以跳上n级。求该青蛙跳上一个n级的台阶总共有多少种跳法。 解题思路:可知本题f(n)=f(1)+f(2)+...+f(n-1)+1;通过数学归纳法得到f(n)=2^(n-1) 1 #include <iostream> 2 using 阅读全文
posted @ 2017-05-09 10:07 qqky 阅读(156) 评论(0) 推荐(0) 编辑
摘要: 题目描述 一只青蛙一次可以跳上1级台阶,也可以跳上2级。求该青蛙跳上一个n级的台阶总共有多少种跳法。 解题思路:f(n)=f(n-1)+f(n-2);且0 1 2需要单独处理 1 #include <iostream> 2 using namespace std; 3 class Solution 阅读全文
posted @ 2017-05-09 09:57 qqky 阅读(173) 评论(0) 推荐(0) 编辑