Widest Vertical Area Between Two Points Containing No Points | Leetcode 1637

Sdílet
Vložit
  • čas přidán 19. 12. 2023
  • Whatsapp Community Link : www.whatsapp.com/channel/0029...
    This is the 77th Video of our Playlist "Arrays (1-D & 2-D) : Popular Interview Problems".
    In this video we will try to solve an easy observation array problem - Widest·Vertical·Area·Between·Two·Points·Containing·No·Points (Leetcode 1637).
    I will explain the intuition so easily that you will never forget and start seeing this as cakewalk EASYYY.
    We will do live coding after explanation and see if we are able to pass all the test cases.
    Also, please note that my Github solution link below contains both C++ as well as JAVA code.
    Problem Name : Widest·Vertical·Area·Between·Two·Points·Containing·No·Points
    Company Tags : Google
    My solutions on Github(C++ & JAVA) : github.com/MAZHARMIK/Intervie...
    Leetcode Link : leetcode.com/problems/widest-...
    My DP Concepts Playlist : • Roadmap for DP | How t...
    My Graph Concepts Playlist : • Graph Concepts & Qns -...
    My GitHub Repo for interview preparation : github.com/MAZHARMIK/Intervie...
    Subscribe to my channel : / @codestorywithmik
    Instagram : / codestorywithmik
    Facebook : / 100090524295846
    Twitter : / cswithmik
    Approach Summary : The goal is to find the maximum width of a vertical area between any two points when the points are sorted based on their x-coordinates. The approach involves sorting the points in ascending order based on their x-coordinates and then iterating through the sorted array to calculate the maximum horizontal distance between adjacent points. The result is the maximum width of a vertical area between any two points in the given set. The final result is returned by the method.
    ╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
    ║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
    ╠╗║╚╝║║╠╗║╚╣║║║║║═╣
    ╚═╩══╩═╩═╩═╩╝╚╩═╩═╝
    ✨ Timelines✨
    00:00 - Introduction
    #coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #hindi #india #coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge#leetcodequestions #leetcodechallenge #hindi #india #hindiexplanation #hindiexplained #easyexplaination #interview#interviewtips #interviewpreparation #interview_ds_algo #hinglish #github #design #data #google #video #instagram #facebook #leetcode #computerscience #leetcodesolutions #leetcodequestionandanswers #code #learning #dsalgo #dsa

Komentáře • 26

  • @wearevacationuncoverers
    @wearevacationuncoverers Před 6 měsíci +2

    Thanks for pushing me everyday to solve at-least one problem. My streak has reached 157 now . All thanks to you

  • @RanjeetKumarceb
    @RanjeetKumarceb Před 6 měsíci +2

    please make a playlist on recursion concept and question

  • @sauravchandra10
    @sauravchandra10 Před 6 měsíci

    Definitely an easy one, my approach:
    class Solution {
    public:
    int maxWidthOfVerticalArea(vector& points) {
    sort(points.begin(),points.end());
    int ans=0;
    for(int i=1;i

  • @wakeuppeggy
    @wakeuppeggy Před 6 měsíci

    ThankYou Mik Sir!

  • @souravjoshi2293
    @souravjoshi2293 Před 6 měsíci

    consistency king 🔥

  • @tutuimam3381
    @tutuimam3381 Před 6 měsíci +1

    Amazing ❤❤❤

  • @oqant0424
    @oqant0424 Před 6 měsíci

    U made it a cakewalk
    Thanks 💖💖
    Done [21.12.23] ✅✅

  • @swastik07
    @swastik07 Před 6 měsíci

    temp = []

    for point in points:

    temp.append(point[0])

    n = len(temp)

    prev = float('-inf')

    temp.sort()

    for i in range(n-1):

    if abs(temp[i]-temp[i+1]) > prev:

    prev= abs(temp[i]-temp[i+1])

    return prev

  • @prateekgirilateralentry5865
    @prateekgirilateralentry5865 Před 6 měsíci +2

    Thank sir for daily motivation Day : 35 streak continues 😃

  • @lofireverbz-wy7go
    @lofireverbz-wy7go Před 6 měsíci

    able to solve this bhaiya but still came here for explanation !!!!!!

  • @technicalguy.
    @technicalguy. Před 6 měsíci

    Sir, I admire your teaching style. Could you create a video explaining LeetCode problem 'Reverse Nodes in k-Group' (Problem 25)? I would greatly appreciate it. Thank you! ❤

  • @aabirchakraborty3033
    @aabirchakraborty3033 Před 6 měsíci +1

    bro apke question ki explaination dekh ke hi , I just solved it😂. They really messed up the explaination of this question.

  • @saurabhKumar-hj6yp
    @saurabhKumar-hj6yp Před 6 měsíci

    ❤❤

  • @RUSTYYYYYYYYY
    @RUSTYYYYYYYYY Před 6 měsíci

    phele mai socha interval ka question hai fir dekha y axis se koi lena dena hi nhi

  • @bhartendupant8859
    @bhartendupant8859 Před 6 měsíci

  • @Ramneet04
    @Ramneet04 Před 6 měsíci

    Hi bhaiya, i have been since a year now about to complete react and already did dsa just solving one or two questions per day, i am now completely exausted and have like no mood to do anything, i just have my laptop open all day, try to code but suddenly start having headache, having my med sem next week, having like 0 motivation. I don't want to leave it and want to maintain my consistency but I'm just exhausted a lot, what should i do?

    • @codestorywithMIK
      @codestorywithMIK  Před 6 měsíci

      Hi Ramneet,
      This happened to me, this happens to almost everyone.
      Because, our body and mind needs break sometimes.
      Let’s not spoil your mid-semester. First take some break from Leetcode(dsa), and focus on your mid-semester exams.
      Once the exams are over, take 2-3 days rest and then resume your practice.
      It will give you a boost. Our brain needs rest to perform even better.

    • @Ramneet04
      @Ramneet04 Před 6 měsíci

      @@codestorywithMIK ah we'll thx a lot for I'll do the same just will do only one potd of the day, and wilk continue after week or so ... Again.❣️

  • @Raj10185
    @Raj10185 Před 6 měsíci

    Problem statement wiered hai bas baki question easy hai

  • @pintushkumar7542
    @pintushkumar7542 Před 6 měsíci

    Java Solution
    class Solution {
    public int maxWidthOfVerticalArea(int[][] points) {

    Arrays.sort(points , ( a , b) ->{
    return a[0]-b[0];
    });
    int widestArea = Integer.MIN_VALUE;
    for(int i=1;i

  • @dayashankarlakhotia4943
    @dayashankarlakhotia4943 Před 6 měsíci

    class Solution {
    public int maxWidthOfVerticalArea(int[][]points){
    Arrays.sort(points,(a,b)->Integer.compare(a[0],b[0]));
    int maxArea=0;
    for(int i=1;i

  • @GauravThinks
    @GauravThinks Před 6 měsíci

    Simply, this solution is O(N*logN) in time + O(1) in space complexity.
    I have a solution with Time= O(N) , space= O(N)
    class Solution {
    public:
    int maxWidthOfVerticalArea(vector& points) {
    int n = points.size();

    priority_queue maxh;
    for(auto it: points) maxh.push(it[0]);
    int maxi= 0;
    int prev=maxh.top();
    maxh.pop();
    while(!maxh.empty()){
    int wide= abs(maxh.top()- prev);
    maxi= max(maxi, wide);
    prev= maxh.top();
    maxh.pop();
    }
    return maxi;
    }
    };

    • @codestorywithMIK
      @codestorywithMIK  Před 6 měsíci +1

      Hi there,
      Actually heap takes logn time in push and pop.
      Hence it will also be nlogn approach.
      Thank you for sharing this approach 👍🏻🙏❤️

    • @GauravThinks
      @GauravThinks Před 6 měsíci

      @@codestorywithMIK oops my bad, thankyou for correcting me 🙂