LeetCode-Solutions-in-Cpp17

Solutions to high-frequency interview questions of LeetCode in C++17, taking into account both efficiency and comprehensibility.


Project maintained by downdemo Hosted on GitHub Pages — Theme by mattgraham
class Solution {
 public:
  int maxArea(vector<int>& height) {
    int res = 0;
    int l = 0;
    int r = size(height) - 1;
    while (l != r) {
      if (height[l] < height[r]) {
        res = max(res, (r - l) * height[l]);
        ++l;
      } else {
        res = max(res, (r - l) * height[r]);
        --r;
      }
    }
    return res;
  }
};