Container With Most Water - (Meta, Google, Amazon) : Explanation ➕ Live Coding 🧑🏻💻👩🏻💻
Вставка
- Опубліковано 12 вер 2024
- In this video we will try to solve another famous Array Qn based on the Greedy 2-Pointer technique “Container With Most Water”.
We will do live coding after explanation and see if we are able to pass all the test cases.
Problem Name : Container With Most Water
Company Tags : Bloomberg, Facebook, Google, Amazon, Adobe
Leetcode Link : leetcode.com/p...
Similar GfG Link : practice.geeks...
My solutions on Github : github.com/MAZ...
My GitHub Repo for interview preparation : github.com/MAZ....
Subscribe to my channel : www.youtube.co....
╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝
Thank you
#coding #helpajobseeker #easyrecipes
#interviewpreparation #interview_ds_algo #hinglish
He never asked us for like , share and subscribe 🙇♂. A True GEM...
Thank you so much. When I first read the question I was afraid that its too difficult and when you read the question I was able to do it on my own without listening to the whole explanation.
same
class Solution {
public:
int maxArea(vector& height) {
int maxwater = 0;
int left = 0;
int right = height.size()-1;
while(left < right){
maxwater = max(maxwater, min(height[left], height[right])*(right-left));
if(height[left] < height[right]){
left++;
}
else{
right--;
}
}
return maxwater;
}
};
Ur explanations , the way of teaching .... big fan sir really feeling blessed
I am watching the solution after the interview.
I was asked how and why we were moving two pointers.
I got the answer.
We have to find a minimum of two heights of left and right pointer
Since we are decreasing the width, to maximize the water contained we will move the pointer pointing to a smaller height.
which Company Bro?
Amazing explanation
You are the best bro !!!🙏🙏
And so are you Prashu
Thank you so much 🙏❤️😇
god level explanation brother
omg why i didn't find this channel earlier
cant we apply trapping rain water problem logic with modification ?
sir how this question is different from maximum area histogram
same doubt
in that we were seeing consecutive heightss to form a rectangle by using the concept of nsl and nsr of stack by taking the current idx height but there isnt any consecutiveness , but here we are storing the water even if the heights in b/w are smaller or bigger we can take them cos water will be stored b/w so we dont care what heights are coming in b/w but in the histogram one if the fluctuation of heights occured our rectangle will be disformed which we dont want
Bhai aapke subscriber bhut tezz badd rhe
Badhai ho
when the height is same why are we allowed to shift any of them i and j . because in the above question when both i and j if we move i then the maxArea is 24 but if we move from j then it will be 16
same question
whatever you choose .. will it effect maximum?
Day 3