From 8972fe929894d96211228f29df4a6e31169a2e25 Mon Sep 17 00:00:00 2001 From: Ashutosh Tiwari Date: Sun, 29 Sep 2024 18:24:24 -0500 Subject: [PATCH] ADD: Continer with most water problem --- .../Day7/container_with_most_water.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 XDaysChallenge/90DaysChallenge/Day7/container_with_most_water.cpp diff --git a/XDaysChallenge/90DaysChallenge/Day7/container_with_most_water.cpp b/XDaysChallenge/90DaysChallenge/Day7/container_with_most_water.cpp new file mode 100644 index 0000000..35fcbef --- /dev/null +++ b/XDaysChallenge/90DaysChallenge/Day7/container_with_most_water.cpp @@ -0,0 +1,17 @@ +// https://leetcode.com/problems/container-with-most-water/description/ + +/** + * Problem requires understanding of two pointer approach + */ +class Solution { +public: + int maxArea(vector& height) { + int currMax=0; + for(int i=0, j=height.size()-1;iheight[j]) --j; + else ++i; + } + return currMax; + } +}; \ No newline at end of file