int maxArea(std::vector<int> &height) {
auto leftIter = height.begin();
auto rightIter = height.end() - 1;
auto *lowerIter = &leftIter;
auto step = 0;
auto output = -1;
auto outputTmp = -1;
while (leftIter != rightIter) {
lowerIter = *leftIter.base() < *rightIter.base() ? &leftIter : &rightIter;
step = *leftIter.base() < *rightIter.base() ? 1 : -1;
outputTmp = *lowerIter->base() * (rightIter - leftIter);
if (outputTmp > output)
{
output = outputTmp;
}
*lowerIter += step;
}
return output;
}
* Your runtime beats 5.31 % of cpp submissions
* Your memory usage beats 5.02 % of cpp submissions (57.9 MB)