
算法
普通网友
这个作者很懒,什么都没留下…
展开
-
LeetCode【70】Climbing Stairs
根据题目找规律,见下表策略选择 分析:斐波那契数列的变形 1 1 2 3 5 8 …… 本题将第二个数字1换成数字2,形成新的相同算法的数列 1 2 3 5 8 13 …… AC代码: public class Solution { public int climbStairs(int原创 2017-06-23 10:52:36 · 578 阅读 · 0 评论 -
LeetCode【69】 Sqrt(x)
public class Solution { public int mySqrt(int x) { return (int)Math.sqrt(x); } } 这个题目很水,只要调用java的函数即可,但是要注意和函数返回类型相同,对sqrt(x)进行类型转换。原创 2017-06-23 10:13:28 · 524 阅读 · 0 评论 -
LeetCode【58】Length of Last Word
public class Solution { public int lengthOfLastWord(String s) { return s.trim().length()-s.trim().lastIndexOf(' ')-1; } }原创 2017-06-22 15:58:40 · 451 阅读 · 0 评论 -
FZU1054阅读顺序 & c++中getchar和gets函数解析
http://acm.fzu.edu.cn/problem.php?pid=1054 这是一道反转字符串问题。 思路: 1.输入字符串个数 2.获取输入的字符串 3.反转,输出。 最后AC代码如下 #include #include #include using namespace std; int main (){ int numbe原创 2017-05-15 21:54:09 · 705 阅读 · 0 评论