diff --git a/maxArea.cpp b/maxArea.cpp new file mode 100644 index 0000000..7953fd9 --- /dev/null +++ b/maxArea.cpp @@ -0,0 +1,30 @@ +#include +#include + +using namespace std; + +class Solution +{ +public: + int maxArea(vector &height) + { + int maxArea = 0; + for(int i = 0; i < height.size(); i++) + { + for(int j = i + 1; j < height.size(); j++) + { + int area = min(height[i], height[j]) * (j - i); + maxArea = max(maxArea, area); + } + } + return maxArea; + } +}; + +int main() +{ + vector height = {1, 8, 6, 2, 5, 4, 8, 3, 7}; + Solution s; + cout << s.maxArea(height); + return 0; +} \ No newline at end of file