这个是O(n2)的排序的总结 /* bubble sort */public static void sortIntegers(int[] A) { // Write your code here int len = A.length; if (len == 0) return; for (int ...
分类:
其他好文 时间:
2016-12-24 02:09:33
阅读次数:
153
// Ref: https://segmentfault.com/a/1190000003811581// Ref: http://www.cnblogs.com/grandyang/p/4383632.html /*如果选择了抢劫上一个屋子,那么就不能抢劫当前的屋子,所以最大收益就是抢劫上一个屋子 ...
分类:
其他好文 时间:
2016-12-22 06:56:28
阅读次数:
184
这道题参考了这个网址: http://blog.csdn.net/u012490475/article/details/48845683 /* 首先考虑边界情况,当有1层时,有一种方法。 然后再看2层时,有1+1、和2+0,两种方法。 再看3层时,首先有两种选择:走一步或者走两步。 如果走两步,那后 ...
分类:
其他好文 时间:
2016-12-20 07:17:20
阅读次数:
136
Write an algorithm which computes the number of trailing zeros in n factorial. Have you met this question in a real interview? Yes Write an algorithm ...
分类:
其他好文 时间:
2016-12-20 00:23:16
阅读次数:
131
/* 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 ...
分类:
其他好文 时间:
2016-12-19 08:47:39
阅读次数:
153
题目链接:http://www.lintcode.com/zh-cn/problem/max-points-on-a-line/# 条件:给一个点数组 目标:求出共线的点的最多个数 实现:时间复杂度——O(n^2) 要考虑的特殊情况是:①有相同点(这个也太特喵隐蔽了)②斜率不存在的点 思路:暴力求解 ...
分类:
其他好文 时间:
2016-12-15 07:23:36
阅读次数:
221
Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining. ...
分类:
移动开发 时间:
2016-12-13 07:44:18
阅读次数:
256
Given an integers array A. Define B[i] = A[0] * ... * A[i-1] * A[i+1] * ... * A[n-1], calculate B WITHOUT divide operation. Have you met this question ...
分类:
编程语言 时间:
2016-12-05 01:52:03
阅读次数:
142
2016.12.4, 366 http://www.lintcode.com/en/problem/fibonacci/ 一刷使用递归算法,超时。二刷使用九章算术的算法,就是滚动指针的思路,以前写python的时候也玩过,但是给忘了,这次又用c++拾起来了。lint有bug,不能用,很烦。 clas ...
分类:
其他好文 时间:
2016-12-04 07:38:08
阅读次数:
246
Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction ...
分类:
其他好文 时间:
2016-12-04 06:52:52
阅读次数:
146