随笔分类 -  LeetCode__Array

摘要:Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. 阅读全文
posted @ 2017-07-28 21:27 mstark 阅读(165) 评论(0) 推荐(0)
摘要:思考的方向不对,即使用了多于别人几倍的时间,也不一定能够达到终点。 我的错误的想法(可以跳过):在leetcode上面做的第四道题,走路一个很大的弯路,收到之前做过的 Container With Most Water 的思路的影响,自己也想到了可以使用两个指针从左右遍历数组, 然而自己在这里走偏了 阅读全文
posted @ 2017-07-28 21:20 mstark 阅读(205) 评论(0) 推荐(0)
摘要:题目: Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two e 阅读全文
posted @ 2017-07-25 21:38 mstark 阅读(239) 评论(0) 推荐(0)
摘要:做leetcode题目的第二天,我是按照分类来做的,做的第一类是Array类,碰见的第二道题目,也就是今天做的这个,题目难度为hard。题目不难理解,但是要求到了时间复杂度,就需要好好考虑使用一下算法了。刚开始没啥思路,就用暴力的方法,用双层循环遍历的一下两个已经排好序的数组 ,在中间位置停止找道中 阅读全文
posted @ 2017-07-25 19:41 mstark 阅读(188) 评论(0) 推荐(0)
摘要:Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have ex 阅读全文
posted @ 2017-07-24 00:09 mstark 阅读(244) 评论(0) 推荐(0)