From 3c68df475afaa018ae34b66c21464f224ac3310f Mon Sep 17 00:00:00 2001 From: Saurabh-269 <115521321+Saurabh-269@users.noreply.github.com> Date: Sun, 23 Oct 2022 19:23:46 +0530 Subject: [PATCH] Container With Most Water Leetcode --- Container With Most Water.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Container With Most Water.cpp diff --git a/Container With Most Water.cpp b/Container With Most Water.cpp new file mode 100644 index 0000000..87a4e02 --- /dev/null +++ b/Container With Most Water.cpp @@ -0,0 +1,30 @@ +class Solution { +public: + int maxArea(vector& height) { + int m=height.size(); + int temp=0,rem=0; + int f=0,l=m-1; + while(f!=l) + { + if(height[f]rem) + { + rem=temp; + } + } + else + { + temp=height[l]*(l-f); + l--; + if(temp>rem) + { + rem=temp; + } + } + } + return rem; + } +};