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

КОМЕНТАРІ • 21

  • @Kunalbindra
    @Kunalbindra 3 місяці тому +8

    He never asked us for like , share and subscribe 🙇‍♂. A True GEM...

  • @isha25tripathi12
    @isha25tripathi12 4 місяці тому +3

    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.

  • @rode_atharva
    @rode_atharva 2 місяці тому +1

    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;
    }
    };

  • @sonukumarram1880
    @sonukumarram1880 6 місяців тому +3

    Ur explanations , the way of teaching .... big fan sir really feeling blessed

  • @surajsidar3280
    @surajsidar3280 3 місяці тому

    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.

  • @tutuimam3381
    @tutuimam3381 Рік тому +2

    Amazing explanation

  • @prashupandey1304
    @prashupandey1304 10 місяців тому +2

    You are the best bro !!!🙏🙏

    • @codestorywithMIK
      @codestorywithMIK  10 місяців тому

      And so are you Prashu
      Thank you so much 🙏❤️😇

  • @saketjaiswal9381
    @saketjaiswal9381 4 місяці тому +1

    god level explanation brother

  • @ikitayadav3272
    @ikitayadav3272 Місяць тому

    omg why i didn't find this channel earlier

  • @abcd76820
    @abcd76820 6 місяців тому

    cant we apply trapping rain water problem logic with modification ?

  • @DeepakSingh-fd2ix
    @DeepakSingh-fd2ix 9 місяців тому +1

    sir how this question is different from maximum area histogram

    • @harchitgulati3065
      @harchitgulati3065 7 місяців тому

      same doubt

    • @parul15137
      @parul15137 4 місяці тому

      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

  • @harshsingh7713
    @harshsingh7713 6 місяців тому

    Bhai aapke subscriber bhut tezz badd rhe
    Badhai ho

  • @Codenow10222
    @Codenow10222 4 місяці тому

    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

  • @AnkitJain-w3l
    @AnkitJain-w3l 6 місяців тому

    Day 3