- 博客(11)
- 收藏
- 关注
原创 n级阶梯,每次走一步或两步,问最多有多少种走法
遇到这道题两次了,现在来总结下。 方法一:运用组合数学的思想。假设在整个过程中,我有k次走了两步,那么剩下的n-2k次我走的都是一步,那么我总的走的步数是k+n-2k。则结果为从n-k里面选了k次走两步,结果为,代码如下:public BigDecimal jiecheng(int n){ if(n==0||n==1){ return new BigDecimal
2015-04-09 23:50:16
7450
翻译 leetcode:Longest Palindromic Substring
这道题目真是弄了很久啊,然后查了好多相关知识,哎,貌似一直很焦躁,我这是怎么了,不能继续这么下去啊,加油! 英文原文地址:http://leetcode.com/2011/11/longest-palindromic-substring-part-i.html1.回文简介 首先,介绍下回文的含义。回文就是对称的序列,无论从前往后读,还是从后往前读,都是一样的。例如,“a
2015-03-03 00:23:41
609
转载 leetcode:Fraction to Recurring Decimal
原文地址:http://blog.youkuaiyun.com/ljiabin/article/details/42025037【题目】Given two integers representing the numerator and denominator of a fraction, return the fraction in string format.If the
2015-02-26 23:21:57
391
转载 Java Arrays的10种最重要的方法
原文地址:http://www.programcreek.com/2013/09/top-10-methods-for-java-arrays/The following are top 10 methods for Java Array. They are the most voted questions from stackoverflow.0. Declare an arra
2015-02-14 15:35:30
444
转载 深入理解Arrays.sort()
中文译文链接: http://blog.youkuaiyun.com/renfufei/article/details/16359297英文原文链接: http://www.programcreek.com/2013/11/arrays-sort-comparator/Arrays.sort(T[],Comparatorsuper T > c) 方法用于对象数组按用户自定义规则排序
2015-02-14 15:01:30
304
转载 Leetcode:Largest Number
【题目】Given a list of non negative integers, arrange them such that they form the largest number.For example, given [3, 30, 34, 5, 9], the largest formed number is 9534330.Note: The resu
2015-02-13 17:41:09
305
原创 Leetcode:Repeated DNA Sequences
开始看到题目,觉得就是直接从第一个子字符串开始遍历,并存储在List中,如果某个子字符串出现两次,就将其添加到结果列表中。结果TLE(Time Limited Exceeded)了。代码如下:public class Solution { public List findRepeatedDnaSequences(String s) { List res
2015-02-12 01:10:21
2492
原创 Leetcode:Binary Search Tree Iterator
最近真是各种私事,也顺便给自己懒惰的机会了。今天开始要继续坚持!看了这道题,顿时觉得自己太挫,Binary Search Tree居然不知道什么意思。赶紧百度搜索了下。下面这篇文章其实就挺简单易懂的。不知道的童鞋学习下。http://www.cnblogs.com/elaron/archive/2013/04/11/3015155.htm。Binary Search Tree,即二
2015-02-10 00:16:24
398
原创 Leetcode: Factorial Trailing Zeroes
第一天开始刷题,努力脱离小白路线,希望可以坚持!这道题目开始都没有看懂题意,然后努力找翻译,结果就直接看到别人答案了,囧~题目意思是:求n!的末尾的0的个数;解法参考:http://www.tuicool.com/articles/RZZnQf大致思路是:末尾的0是由1*2*3*...*n式子中的"2*5"产生,因此需要判断n!中包含多少个2,5因子;对
2015-01-14 17:12:05
1023
原创 LeetCode:Minimum Depth of Binary Tree
LeetCode第二话,其实中间也写了其他题,但是较为简单,就不赘述了。这道题,一上来,又理解错了,一直以为是用广度优先来一层一层的搜索哪个节点没有两个子节点。结果一测试,当只有两个节点时,结果居然为2,感觉太不可思议了,所以赶紧跑去看看人家怎么理解题目的。就看到这篇http://blog.youkuaiyun.com/andrewseu/article/details/28595541。题目为:Give
2015-01-14 15:49:34
403
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人