摘要:
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.The above elevation map is represented by array [0,1,0,2,1,0,1,3,2,1,2,1]. In this case, 6 units of 阅读全文
摘要:
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.本题要求在O(n)时间内完成,并且使用O(1)空间O(n)时间则说明要使用hash来解本题,O(1)空间要求不能另开一个数组来进行hash,只能声明变量或者使用输入数组来进行这题是使用输入数组来进行hash本题的输入正整数范 阅读全文