1000000000 1000000000 [2] [2] this case isnt working for me:(
@yogeshyogesh29232 жыл бұрын
good explanation but my dumb mind is not understanding 😭😭
@yogeshyogesh29232 жыл бұрын
Yeh i just understand 😊 the solution
@Anonymous-ps8cv2 жыл бұрын
What if maxHeight*maxWidth is exceeding long limit too? Then how to return answer in % ?
@sixsided38252 жыл бұрын
Use maxHeight = maxHeight % (1e9+7); maxWIdth = maxWidth % (1e9+7); and then 1L * maxHeight * maxWidth is guaranteed to be within max value of long since 1e9+7 * 1e9+7 is less than max value of long.
@vaibhavvashist2382 жыл бұрын
if heights of one of the cuts is max then then width of that cut is also max
@tathagatnegi59233 жыл бұрын
Thanks
@CodeWithSunchitDudeja3 жыл бұрын
Thnx
@devanshsrivastava97513 жыл бұрын
Great Explanation in a very cool way... Really liked and keep uploading
@CodeWithSunchitDudeja3 жыл бұрын
Thnx Devansh
@algorithmo1343 жыл бұрын
Can you do a video where you code while explaning after the visual explanation instead of the code showing already? It would be much better
@CodeWithSunchitDudeja3 жыл бұрын
I previously used to do it, check my old videos. Later I thought it becomes boring for the viewers so switched to this mode
@algorithmo1343 жыл бұрын
@@CodeWithSunchitDudeja it is not boring
@ojasvichaudhary87243 жыл бұрын
can you please tell me what is 1L and why we multiply with that ?
@CodeWithSunchitDudeja3 жыл бұрын
Conversion to long from int
@ojasvichaudhary87243 жыл бұрын
(long)maxHeight*maxWidth will also work ?
@CodeWithSunchitDudeja3 жыл бұрын
👍
@sayantaniguha85193 жыл бұрын
@@ojasvichaudhary8724 *long ans = long(maxHeight * maxWidth);* doesn't work but *long ans = (long)maxHeight * (long)maxWidth;* works
@siddharthkumar27613 жыл бұрын
Why converting to long and reverting back to int, can't we do modulo multiplication => (maxHeight%1000000007 * maxWidth%1000000007)%1000000007 ...?
@anshumangupta10013 жыл бұрын
Because maxHeight and maxWidth are given in int and also we have to return in int..!
@CodeWithSunchitDudeja3 жыл бұрын
It will work here 👍
@karanalang15733 жыл бұрын
one suggestion .. pls spend a minute explaining the problem (esp in this problem, the verbiage is a bit confusing), i thought you jumped to the solution immediately
@CodeWithSunchitDudeja3 жыл бұрын
Acknowledged
@shubhamkumbhare27253 жыл бұрын
I dont understand the last part where you did the multiplication with the 1L and on retrun you divided with the 10000007 . Why we need to do this ?
@akshayalok75803 жыл бұрын
This is a requirement by the question
@RitikSingh-bt3gp3 жыл бұрын
it is multiplied by 1L so that the long ans can store the value , the limit of the long int is 10^12 , if we don't do this and simply store the value in int ans (which has limit of 10^7 only) the ans will not be able to accommodate.
@CodeWithSunchitDudeja3 жыл бұрын
+1 to what @Akshay and @Ritik said, in order to avoid overflow conditions we have to do it.
@resumeprojects7823 жыл бұрын
@@RitikSingh-bt3gp I understand the question says to do 10000007 , But why exactly that? why not 10000008? or 10000009?
@RitikSingh-bt3gp3 жыл бұрын
@@resumeprojects782 The number taken for mod should just be large enough to fit in the largest integer data type i.e it makes sure that there is no overflow in the result. It should be a prime number because if we take mod of a number by Prime the result is generally spaced i.e. the results are very different results in comparison to mod the number by non-prime, that is why primes are generally used for mod. 10^9+7 fulfills both the criteria. It is the first 10-digit prime number and fits in int data type as well. In fact, any prime number less than 2^30 will be fine in order to prevent possible overflows.
@tanyagupta38463 жыл бұрын
Wow, awesome
@akshayalok75803 жыл бұрын
Bro why do we need to sort the array? if we just need max dimension... and the max dimension = max gap between two elements of the array, can't we use pigeonhole to find max height and width and reduce further to Constant * O(n) complexity? PS: Btw I tried both approaches and the approach where I sort the array is getting lesser runtime (probably because leetcodes test cases have many arrays of small lengths in which case pigeonhole is comparable or worse than sorting and iterating)
@CodeWithSunchitDudeja3 жыл бұрын
We are not given the widths or the heights in the questions. We need to calculate it from the coordinates. Your solutions looks interesting, curious to know how it works, can you raise a PR in github.com/Sunchit/Coding-Decoded appending your solution to mine. I will be glad if you do it.
@akshayalok75803 жыл бұрын
@@CodeWithSunchitDudeja Check it out, although the solution is in python and I am not so sure about readability :p