Minimum Cost to Make Array Equal II Ternary Search II Weighted Median II Binary Search II Greedy

  Рет қаралды 6,653

Aryan Mittal

Aryan Mittal

Күн бұрын

Пікірлер: 52
@ARYANMITTAL
@ARYANMITTAL Жыл бұрын
Checkout DSA-169 Series: kzbin.info/www/bejne/a3PYfImJYruhrdU Code & Notes: drive.google.com/file/d/1IFmbHdOZW0LeU6wGknewJxOd5dDyFsJU/view?usp=sharing This is one of the kinds, we have not seen in last 2-3 months, toh ye jaror kar lena ❤
@benoitblanc-zl8rc
@benoitblanc-zl8rc Жыл бұрын
@Aryan pls discuss weekly contest 350 There was question of dp + bitmask
@samratgupta731
@samratgupta731 Жыл бұрын
@@benoitblanc-zl8rc ++
@visase2036
@visase2036 Жыл бұрын
This is crazy! Thanks for being very intuitive. Definitely , Indian LEE . IYKYN!
@sahilanand30
@sahilanand30 Жыл бұрын
Super helpful videos Please never stop making these Leetcode daily problems videos
@priyanshutiwari7368
@priyanshutiwari7368 Жыл бұрын
it was a spectacles..skeptical ..oh sry spectacular to watch you solve this so effortlessly
@tolulopemalomo8922
@tolulopemalomo8922 7 ай бұрын
Thank you so much for this video 😭. I watched like three videos before finding yours and no one explained it this well 🙏🏽
@rohitsinha190
@rohitsinha190 Жыл бұрын
You need patience to watch the complete video 😅. The first real life example of why each friend should meet at the median and the weighted median approach to solve the problem actually sets the stage to understand the concept of convex graph. Brilliantly explained👌👌
@pranshu_awasthi
@pranshu_awasthi Жыл бұрын
The actual time complexity in the first approach would be O(n2) as we're moving ahead in the nums array , and for each value of nums till a certain point , we're further traversing the entire array and calculating cost.
@devanshpurwar
@devanshpurwar Жыл бұрын
your consistency, explanation very helpful
@paritoshpareek8860
@paritoshpareek8860 Жыл бұрын
Beautifully explained ! Loved the way you bring the concept into the picture
@pradeepballa2712
@pradeepballa2712 Жыл бұрын
appreciate the effort you have put in this by the way very clear explaination
@gourabchatterjee1778
@gourabchatterjee1778 Жыл бұрын
Really well explained
@shashwatsrivastava5332
@shashwatsrivastava5332 Жыл бұрын
Similar to SPOJ Problem of Building Construction.
@VikasGupta-ok9lh
@VikasGupta-ok9lh Жыл бұрын
while reading the question i came up with the idea of binary search but i was stuck with the part when to increase my s and when to decrease my end as i was not having any reference for my ans then i refered leetcode articles where it was mentioned regarding convex conditions
@ashishdhal4614
@ashishdhal4614 Жыл бұрын
Could you share the post
@VikasGupta-ok9lh
@VikasGupta-ok9lh Жыл бұрын
@@ashishdhal4614 In @lee solution comment section someone shared the reference
@_MS98
@_MS98 Жыл бұрын
Thanks 🐻‍❄🐻‍❄
@slimshadyyy2427
@slimshadyyy2427 Жыл бұрын
Great bro
@Rajat_Jaiswal
@Rajat_Jaiswal Жыл бұрын
best
@aditimahabole1761
@aditimahabole1761 Жыл бұрын
very nice explanation... you did not upload june 22 leetcode daily problem that is buy and sell stock 2 ..can you please do it ...your explanations are tooo good.
@tolulopemalomo8922
@tolulopemalomo8922 7 ай бұрын
Btw, I can't access the code, can you share on replit or something
@RahulMaurya-tc2wi
@RahulMaurya-tc2wi Жыл бұрын
Could you please explain why we have taken (sum+1)/2, I do understand that for odd no. of observations it is (sum+1)/2 but not for even no. of observations and why simple sum/2 won't work?
@sriharsha519
@sriharsha519 Жыл бұрын
(sum+1) just works for both odd and even, but sum/2 only works for even, take example of 10 and 11, the median of 10 is 10+1/2 with is 11/2 which is 5 , as its int , but when we have 11 , median is 12/2 which is correct , but 11/2 will give us 5, which is incorrect , so we need to take sum+1/2
@RahulMaurya-tc2wi
@RahulMaurya-tc2wi Жыл бұрын
@@sriharsha519 got it , Thanks for explaining with example.
@karankulshrestha4708
@karankulshrestha4708 Жыл бұрын
Bro your solutions are too complex to understand please try make them simple because beginners like me coming to your channel, Its a humble request and write code from scratch it. Thank you otherwise you are doing good work.🙂
@SlapB0X
@SlapB0X Жыл бұрын
this is a hard level problem and his code was the simplest code for this problem. i think you should give a lil time to medium level questions first before jumping to this.
@bachkhoahuynh9110
@bachkhoahuynh9110 Жыл бұрын
@@SlapB0X his idea is too complicated, and the code uses some unnecessarily complicated methods that increase complexity in understanding. this problem can be solved by using only linear function that 8th grade students can understand. Go to leetcode and find solutions with tags Python and Math for more simpler solutions.
@ashishgoyal6256
@ashishgoyal6256 Жыл бұрын
Bhaiya aaki dsa sheet krunga poori 2 mahine ki chutti hai har roj 2 que krlu or uska jo bhi imp part lage vo sheet mai daalta rahunga kya hai sahi tarikaa hai aapki sheet krne ka
@ARYANMITTAL
@ARYANMITTAL Жыл бұрын
Haan bro, Sath me notes bhi banate chalna either on sheet or offline, koi bhi new concept/technique learn karo toh. And frequency let’s keep it 3-4 questions daily. Because last me ek baar revision bhi karna hoga apan ko 🫶🏻💪🏻
@ashishgoyal6256
@ashishgoyal6256 Жыл бұрын
Ji bhaiya
@tanishkumar6682
@tanishkumar6682 Жыл бұрын
Aryan bhai, I have a doubt that before applying trinary search, first we have to make sure that there must be only one minima or maxima of the graph. So ,we have to conclude by any way that our graph will contain only one maxima or minima. please correct me if i am wrong
@VikasGupta-ok9lh
@VikasGupta-ok9lh Жыл бұрын
when u will plot the graph it will show convex conditions which in itself ensures that it will have either one maxima or one minima
@tanishkumar6682
@tanishkumar6682 Жыл бұрын
@@VikasGupta-ok9lh we can only plot few points to check ,but we cannot be sure that for all the points the behaviour of graph will be same So, I think we have to prove by some reasoning that shape of our graph will be convex throught all the points
@ARYANMITTAL
@ARYANMITTAL Жыл бұрын
As we saw above, extreme min num value and extreme max num value will be the extreme points of this curve. And as we keep on coming inside of the curve i.e. coming close to median, the values/total cost will keep on reducing. Thus, directly applying Trinary search/ Ternary search won’t hit untill we sort nums and see that as we come close to median, it’s value is reducing. Hope that help :)
@VikasGupta-ok9lh
@VikasGupta-ok9lh Жыл бұрын
​ @tanishkumar6682 yes it has mathematical proof and I have seen the proof some one has shared in the comments of leetcode discuss section it was 3 page proof using continuity and limits
@surjamaji4988
@surjamaji4988 Жыл бұрын
why you do res+=1L* abs() what is purpose of 1L?
@msdarshankirthic
@msdarshankirthic Жыл бұрын
To make the multiplication in long datatype so it doesnt throw the integer overflow error, 1L is used to typecast over there
@arghyadas4138
@arghyadas4138 Жыл бұрын
Why shift to median and not to mode?
@anexocelisia9377
@anexocelisia9377 Жыл бұрын
Trinary search or ternary search??
@ARYANMITTAL
@ARYANMITTAL Жыл бұрын
Thanks for bringing out 🙃, my bad !!
@anexocelisia9377
@anexocelisia9377 Жыл бұрын
@@ARYANMITTAL big fan man! but i wish to know to get into gms just like you did as in colleges, good companies doesn't comes
@arpitgupta4466
@arpitgupta4466 Жыл бұрын
why median, why not mean?
@samir3442
@samir3442 Жыл бұрын
why (sum+1) / 2??? not sum / 2
@Its_Shubham_Negi
@Its_Shubham_Negi 28 күн бұрын
sum+1/2 will give us the right median in case number of elements r even
@skasana334
@skasana334 Жыл бұрын
Bhaiya i have solved around 400 questions on leetcode but still i was not able to think about the logic of this question🥲 ,is it a topic of concern?
@priyanshuagrawal2016
@priyanshuagrawal2016 Жыл бұрын
not at all because i have solved 700 still i stuck in between
@ARYANMITTAL
@ARYANMITTAL Жыл бұрын
Yaa true, this one is a different concept, a new one, so getting stuck on this one is normal ❤️
@skasana334
@skasana334 Жыл бұрын
​@@priyanshuagrawal2016 oh thanks
@skasana334
@skasana334 Жыл бұрын
​@@ARYANMITTALthanks bhaiya
@rimurutempest2130
@rimurutempest2130 Жыл бұрын
Bro recently , In Interview , i solved a Hard LC . They still rejected . Crazy , I couldn't think of any real reason . Maybe it was Speed or because interviewer was a Bangladeshi Canadian . Just biases . Crazy world .
Players vs Pitch 🤯
00:26
LE FOOT EN VIDÉO
Рет қаралды 138 МЛН
Муж внезапно вернулся домой @Oscar_elteacher
00:43
История одного вокалиста
Рет қаралды 7 МЛН
快乐总是短暂的!😂 #搞笑夫妻 #爱美食爱生活 #搞笑达人
00:14
朱大帅and依美姐
Рет қаралды 13 МЛН
Do you love Blackpink?🖤🩷
00:23
Karina
Рет қаралды 21 МЛН
Week 2 | Introduction to Numerical Methods using MATLAB
1:40:03
Soumyadeep Chowdhury
Рет қаралды 58
Lec 54: Incompatible Elements #swayamprabha #ch27sp
58:46
CH 27: IIT KANPUR 04: Mechanical Engineering...
Рет қаралды
Binary Search Algorithm - Computerphile
18:34
Computerphile
Рет қаралды 164 М.
Rigid Body Dynamics (RBD)
22:23
Naim Khan
Рет қаралды 27
1611. Minimum One Bit Operations to Make Integers Zero
25:42
Aryan Mittal
Рет қаралды 2,8 М.
Players vs Pitch 🤯
00:26
LE FOOT EN VIDÉO
Рет қаралды 138 МЛН