```
class Solution {
public:
int Min(int x,int y)
{
if(x<y) return x;
return y;
}
int trap(int a[], int n)
{
int count=0,i,start,j;
bool trap;
//while(1)
//{
i=1;
// trap=false;
while(i<=n-2)
{
while(a[i-1]>a[i] && a[i]<=a[i+1])
{
start=i;
while(i<=n-2 && a[i]==a[i+1])
i++;
if(a[i]<a[i+1])
{
count+=(i-start+1)*(Min(a[start-1],a[i+1])-a[start]);
//trap=true;
for(j=start;j<=i;j++)
a[j]=Min(a[start-1],a[i+1]);
j=start;
while(j>=1 && a[j-1]==a[j])
j--;
if(j>=1)
{
if(a[j-1]>a[j])
i=j;
else
break;
}
else
;
}
else
;
}
//else
// ;
i++;
}
// if(trap==false)
// break;
//}
return count;
}
};
```

I use one pass algorithm, and use Min in case that leetcode do not support C++11, but when in case [4,2,3], my local get 1, which is correct, but leetcode OJ said I print out 3, which is not correct, could anybody help me?