From 15a6685e6d3893c42617eb867a497457fcb8f99f Mon Sep 17 00:00:00 2001
From: MITHILESH <mkumar199861@gmail.com>
Date: Thu, 1 Oct 2020 12:42:04 +0530
Subject: [PATCH] Create container_with_most_water.cpp

---
 cpp/container_with_most_water.cpp | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
 create mode 100644 cpp/container_with_most_water.cpp

diff --git a/cpp/container_with_most_water.cpp b/cpp/container_with_most_water.cpp
new file mode 100644
index 0000000000..57dea64c3e
--- /dev/null
+++ b/cpp/container_with_most_water.cpp
@@ -0,0 +1,18 @@
+class Solution {
+public:
+    int maxArea(vector<int>& h) {
+        int n = h.size();
+        int i = 0, j = n - 1;
+        int ans = 0,height;
+        while(i < j)
+        {
+            if(h[i] < h[j]){
+            height = h[i];
+            ans = max(ans, (j - i)*height);i++;}
+            else{
+            height = h[j];
+            ans = max(ans, (j - i)*height);j--;}
+        }
+        return ans;
+    }
+};