摘要:
题目: Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Your goal is to reach the last index in the minimum number of jumps.For example:Given array A =[2,3,1,1,4]The minim
阅读全文
posted @ 2013-07-10 23:13
lichen782
阅读(16822)
推荐(0)
编辑
摘要:
题目:Givennnon-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. For example, Given[0,1,0,2,1,0,1,3,2,1,2,1], return6.例如给出上图中的黑色部分(数组表示),让你求出蓝色部分。这也是个神题。。。当然对小白我来说。想了半天,是不是遍历数组呢,然后依次计算当前bar构成的container大小。问题在于,这个..
阅读全文
posted @ 2013-07-10 19:04
lichen782
阅读(1295)
推荐(0)
编辑
摘要:
题目:Given an unsorted integer array, find the first missing positive integer.For example,Given[1,2,0]return3,and[3,4,-1,1]return2.Your algorithm should run inO(n) time and uses constant space.为什么这道题值得纪念呢? 因为它教育我们看问题看本质。要看出问题本质,首先要深刻理解问题本身是在说啥。。。(越来越像学习某某core的讲话了)在一个无序的整数数组中,找出第一个没有的正数。什么意思呢?这么想,所有正数是
阅读全文
posted @ 2013-07-10 10:08
lichen782
阅读(1089)
推荐(0)
编辑