codility
文章平均质量分 79
willyz_90
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Codility Lesson 3 MinAvgTwoSlice解答
*大多数朋友如果找到这篇文章,就是来看解答的,所以完整的题目放到文章的最后了。思路:1、首先根据题目,大家第一反应就是无脑嵌套遍历所有情况,这样的时间复杂度是O(n^2+n)/2,远远超出O(n)的题目里的要求。2、其次就是找规律了,这个slice一定发生在最小值周围吗?不一定!比如[-1, -1, 12, -9, 10]。所以不用去思考先找到最小值,再向两边递归的思路了。原创 2015-01-10 10:15:28 · 2138 阅读 · 0 评论 -
Codility Lesson 4 NumberOfDiscIntersections 解答
Thinking:1. Look every circle as a range, that will help us think in a simpler way. So the first step is translate circles into ranges(from "center&radius" to range):A[0]=1 >> [-1,1]A[1]=5原创 2015-01-13 07:46:05 · 2007 阅读 · 0 评论 -
Codility Lesson 5 Brackets 解答
Thinking:This lesson is about two kinds of data structures -- queue and stack. After reading the question carefully, you can tell stack is a good choice. As it's a EASY-level question, there is neit原创 2015-01-15 15:18:18 · 1387 阅读 · 0 评论
分享