1. Two Sum(https://oj.leetcode.com/problems/two-sum/)解题思路:解法一: 暴力,O(n2)时间复杂度,TLE解法二:利用hash, 记录下数组中每个值对应的下标,再遍历一遍数组,通过查看target-num[i]的值是否在map中来确定另一个数值。...
分类:
编程语言 时间:
2014-10-24 00:16:44
阅读次数:
226
原题地址:https://oj.leetcode.com/problems/find-minimum-in-rotated-sorted-array/解题思路:话说leetcode上面的二分查找题目真的不少啊。下图是这道题的数组的两种情况,分别去处理就可以了。class Solution: #...
分类:
编程语言 时间:
2014-10-23 16:10:21
阅读次数:
224
原题地址:https://oj.leetcode.com/problems/find-minimum-in-rotated-sorted-array-ii/解题思路:这道题和上一道题的区别是,数组中可能有相同的数。那么,分下列几种情况:代码:class Solution: # @param n...
分类:
编程语言 时间:
2014-10-23 16:07:04
阅读次数:
183
Error The project was not built due to “Problems encountered while deleting resources.”. Fix the problem, then try refreshing this project and rebuild...
分类:
其他好文 时间:
2014-10-23 15:54:04
阅读次数:
218
欢迎交流 1.1.26public class TestApp { public static void main(String[] args) { int a = StdIn.readInt(); int b = StdIn.readInt(); ...
分类:
其他好文 时间:
2014-10-22 20:16:11
阅读次数:
215
根据loadrunner官方文档tutorial试验“Solving Common Playback Problems”时,将所遇见问题总结如下。问题主要有:1.录制与回放后loadrunner无法找出动态值,即2次log的不同之处。2.关联后仍然无法回放成功。解决:录制前,设置的working d...
分类:
其他好文 时间:
2014-10-21 19:11:47
阅读次数:
248
source:https://oj.leetcode.com/problems/find-minimum-in-rotated-sorted-array/Suppose a sorted array is rotated at some pivot unknown to you beforehand...
分类:
编程语言 时间:
2014-10-21 05:39:49
阅读次数:
190
https://oj.leetcode.com/problems/remove-duplicates-from-sorted-array/用一个cnt记录不重复的部分,后面每遇到不重复的cnt++即可。class Solution {public: int removeDuplicates(i...
分类:
编程语言 时间:
2014-10-20 03:23:10
阅读次数:
241
https://oj.leetcode.com/problems/3sum-closest/和3sum类似。不同的是这次需要逼近一个值,实际上跟相等类似,用l和r指针不断移动,然后反复取最小即可。class Solution {public: int n,m; int threeSumC...
分类:
编程语言 时间:
2014-10-19 11:19:59
阅读次数:
156
https://oj.leetcode.com/problems/gas-station/计算每个加油站的加油差diff[]。得到一个数组。从贪心的角度来说,如果我们找到一个最大子串,那么从他的起点l开始走,能够连续一直走并且累积最大量的汽油。一个猜想是:如果这些汽油不足以走完全程,那么无论从哪里都...
分类:
编程语言 时间:
2014-10-19 02:42:38
阅读次数:
177