12 2016 档案
LintCode 463 Sort Integer
摘要:这个是O(n2)的排序的总结 /* bubble sort */public static void sortIntegers(int[] A) { // Write your code here int len = A.length; if (len == 0) return; for (int 阅读全文
posted @ 2016-12-24 00:21 wenchan 阅读(251) 评论(0) 推荐(0)
LintCode 392 House Robber
摘要:// Ref: https://segmentfault.com/a/1190000003811581// Ref: http://www.cnblogs.com/grandyang/p/4383632.html /*如果选择了抢劫上一个屋子,那么就不能抢劫当前的屋子,所以最大收益就是抢劫上一个屋子 阅读全文
posted @ 2016-12-22 00:38 wenchan 阅读(225) 评论(0) 推荐(0)
LintCode 111 Climbing Stairs
摘要:这道题参考了这个网址: http://blog.csdn.net/u012490475/article/details/48845683 /* 首先考虑边界情况,当有1层时,有一种方法。 然后再看2层时,有1+1、和2+0,两种方法。 再看3层时,首先有两种选择:走一步或者走两步。 如果走两步,那后 阅读全文
posted @ 2016-12-20 00:56 wenchan 阅读(232) 评论(0) 推荐(0)
LintCode 366 Fibonacci
摘要:/* 1st method will lead to time limit *//* the time complexity is exponential sicne T(n) = T(n-1) + T(n-2) */ /* 2nd method will need O(n) space, usin 阅读全文
posted @ 2016-12-19 01:04 wenchan 阅读(378) 评论(0) 推荐(0)