![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
枚举和查找
ojshilu
https://github.com/lucky521
展开
-
Find subarray with given sum
问题:Given an unsorted array of integers, find a continous subarray which adds to a given number.注意:数组中有正有负。参见:http://stackoverflow.com/questions/5534063/zero-sum-subarray#include#include#in原创 2014-03-17 20:37:29 · 821 阅读 · 0 评论 -
找出穿过最多点的直线 Max Points on a Line
平面上有若干个点,要你找出一条直线,使其能穿过最多的点。思路:枚举法。求出任意两点之间的线,以直线(斜率,与y轴的交点坐标)的形式存储到map。这样个数最多的直线就是所求。时间O(N^2),空间O(N).注意特殊情况:1、当直线的斜率为无穷大时,其与y轴没有交点,但是和x轴的交点不相同,这时候我需要特殊表示一下。2、点集中有重叠的点时,算几个点?原创 2014-03-20 21:34:52 · 6138 阅读 · 2 评论 -
Leetcode题:Substring with Concatenation of All Words
You are given a string, S, and a list of words, L, that are all of the same length. Find all starting indices of substring(s) in S that is a concatenation of each word in L exactly once and without an原创 2014-03-26 21:23:50 · 5902 阅读 · 0 评论