Widest Vertical Area Between Two Points Containing No Points | Leetcode 1637
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
Thanks for pushing me everyday to solve at-least one problem. My streak has reached 157 now . All thanks to you
please make a playlist on recursion concept and question
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
ThankYou Mik Sir!
consistency king 🔥
Amazing ❤❤❤
U made it a cakewalk
Thanks 💖💖
Done [21.12.23] ✅✅
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
Thank sir for daily motivation Day : 35 streak continues 😃
able to solve this bhaiya but still came here for explanation !!!!!!
❤️🙏
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! ❤
Let me try soon 👍🏻❤️
bro apke question ki explaination dekh ke hi , I just solved it😂. They really messed up the explaination of this question.
❤❤
phele mai socha interval ka question hai fir dekha y axis se koi lena dena hi nhi
❤
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?
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.
@@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.❣️
Problem statement wiered hai bas baki question easy hai
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
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
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;
}
};
Hi there,
Actually heap takes logn time in push and pop.
Hence it will also be nlogn approach.
Thank you for sharing this approach 👍🏻🙏❤️
@@codestorywithMIK oops my bad, thankyou for correcting me 🙂