public int trap1(int[] height) {
		int N=height.length;
		int water=0;
		for (int i=0;i<N-1;){

			if(height[i]==0){
				i++;
				continue;
			}
//			System.out.println("i "+i);
			int maxIndex=i+1;
			for (int j=i+1;j<N;j++){
				if(height[j]>height[maxIndex]){
					maxIndex=j;
				}
				if(height[j]>=height[i]){
					break;
				}
			}
//			System.out.println("maxIndex "+maxIndex);
			int min=height[i]<height[maxIndex]?height[i]:height[maxIndex];
//			System.out.println("min "+min);
			//{1,5,4,3,2,1,2};
			for (int k=i+1;k<maxIndex;k++){
				int tmp = min-height[k];
//				System.out.println("tmp "+tmp);
				water+=tmp;
			}
			i=maxIndex;
		}
		return water;
	}